Skip to content

Instantly share code, notes, and snippets.

@alexvcasillas
Created August 17, 2017 08:34
Show Gist options
  • Save alexvcasillas/66b0f2f35a3871590be721480e61ca25 to your computer and use it in GitHub Desktop.
Save alexvcasillas/66b0f2f35a3871590be721480e61ca25 to your computer and use it in GitHub Desktop.
Webpack CommonChunks Plugin
// CommonChunkPlugin Configuration
new webpack.optimize.CommonsChunkPlugin({
name: 'vendors',
filename: '[hash].vendors.js',
minChunks: function(module, count) {
// this assumes your vendor imports exist in the node_modules directory
// and appears at least in two files
console.log(`Module: ${module.resource} ${count} times`); // DEBUG Purposes
return (
module.context &&
module.context.indexOf('node_modules') !== -1 &&
count === 2
);
}
// Got this when processing a module
Module: undefined 1 times
// Is that maybe the source of the error?
Error: No code sections found
at Bundle.validate (D:\webpack\demo\node_modules\inspectpack\lib\models\bundle.js:43:11)
at Immediate.setImmediate (D:\webpack\demo\node_modules\inspectpack\lib\models\bundle.js:268:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
D:\webpack\demo\node_modules\inspectpack\lib\models\bundle.js:43
throw new Error("No code sections found");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment