Created
February 7, 2016 19:27
-
-
Save puppybits/4246e867887c1f10796f to your computer and use it in GitHub Desktop.
Webpack Chunking. Example from Megatome: React/Webpack starter. https://github.com/Levelmoney/generator-megatome/blob/master/generators/app/templates/_webpack.config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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