Skip to content

Instantly share code, notes, and snippets.

@puppybits
Created February 7, 2016 19:27
Show Gist options
  • Save puppybits/4246e867887c1f10796f to your computer and use it in GitHub Desktop.
Save puppybits/4246e867887c1f10796f to your computer and use it in GitHub Desktop.
var globals = {
React: 'react',
ReactDom: 'react-dom',
ReactRouter: 'react-router'
}
...
{
entry: {
app: ['./src/bootstrap.js'],
libs: Object.keys(globals).map(function(k){ return globals[k]; })
},
output: {
chunkFilename: "[name].js",
filename: "[name].js"
},
module:{
loaders: [{
/* convert all source files */
test: /\.(js|jsx)$/,
include: [/src/,/bower_components/],
exclude: [/(node_modules)/],
loader: 'babel?plugins[]=transform-runtime&presets[]=es2015&presets[]=stage-0&presets[]=react&cacheDirectory=true',
}]
},
}
...
function updateLibs(config, options) {
if(options.commonsChunk) {
config.plugins.push(new webpack.optimize.CommonsChunkPlugin('libs', "libs.js"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment