Skip to content

Instantly share code, notes, and snippets.

@kswedberg
Created July 19, 2016 16:34
Show Gist options
  • Save kswedberg/a8b776d1790de6d7c3df0364b3e69c60 to your computer and use it in GitHub Desktop.
Save kswedberg/a8b776d1790de6d7c3df0364b3e69c60 to your computer and use it in GitHub Desktop.
var webpack = require('webpack');
var config = require('./webpack.config');
var configs = [
config({
entry: {
head: ['app/assets/js/head.js')],
},
outputFile: '[name].js',
chunkFile: '[name].js',
}),
config({
entry: {
tail: [
'babel-polyfill',
'app/assets/js/tail.js'
]
},
outputFile: '[name].[hash].js',
chunkFile: '[name].[chunkhash].js',
})
];
configs.forEach(function(conf) {
webpack(conf, function(err, stats) {
// ...
});
});
module.exports = function(config) {
var loaders = [
{
loader: 'babel',
test: /\.jsx?$/,
include: [
/app\/assets\/js/,
/fmjs/,
],
},
// ...
];
var webpackConfig = {
middlewarePublicPath: '/assets/js/',
entry: config.entry,
output: {
filename: config.outputFile,
chunkFilename: config.chunkFile,
path: 'public/assets/js',
},
module: {
loaders: loaders,
},
devServer: {
host: 'localhost',
port: 8080,
},
// ...
};
return webpackConfig;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment