move webpack config out of sapper, into the app

This commit is contained in:
Rich Harris
2017-12-13 21:35:56 -05:00
parent bffffe0035
commit 7c0789cabf
5 changed files with 76 additions and 86 deletions

43
webpack/config.js Normal file
View File

@@ -0,0 +1,43 @@
const path = require('path');
const route_manager = require('../lib/route_manager.js');
const { src, dest, dev } = require('../lib/config.js');
module.exports = {
dev,
client: {
entry: () => {
return {
main: `${dest}/main.js`
};
},
output: () => {
return {
path: `${dest}/client`,
filename: '[name].[hash].js',
chunkFilename: '[name].[id].js',
publicPath: '/client/'
};
}
},
server: {
entry: () => {
const entries = {};
route_manager.routes.forEach(route => {
entries[route.id] = path.resolve(src, route.file);
});
return entries;
},
output: () => {
return {
path: `${dest}/server`,
filename: '[name].[hash].js',
chunkFilename: '[name].[id].js',
libraryTarget: 'commonjs2'
};
}
}
};