If you had a multi-page application (as opposed to a single page app), you ' re likely sharing modules between these pages. By chunking these common modules to a single common bundle, you can leverage the browser cache much more powerfully. In this lesson we'll use Webpack's commonschunkplugin to easily share common modules between apps.
Const WEBPACK = require (' Webpack ') Const {Resolve}= Require (' path ') Module.exports= ENV = { return{entry: {app:'./js/app.js ', Animalfacts:'./animal-facts/js/app.js ',}, Output: {filename:' Bundle. [Name].js ', Path:resolve (__dirname,' Dist '), PathInfo:!Env.prod,}, Context:resolve (__dirname,' SRC '), Devtool:env.prod? ' Source-map ': ' eval ', Bail:env.prod, module: {loaders: [{test:/\.js$/, loader: ' Babel!eslint ', exclude:/node_modules/}, {test:/\.css$/, loader: ' Style!css '},],}, plugins: [Env.test? Undefined:NewWebpack.optimize.CommonsChunkPlugin ({name:' Common ', FileName:' Bundle.common.js ', chunks: [' App ', ' animalfacts ']}),].filter (P= =!!p),}}
[Webpack 2] Chunking common modules from multiple apps with the Webpack Commonschunkplugin