Skip to content

Instantly share code, notes, and snippets.

@pablohpsilva
Created October 28, 2017 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pablohpsilva/6c80f336b61914497a3063c5257286d5 to your computer and use it in GitHub Desktop.
Save pablohpsilva/6c80f336b61914497a3063c5257286d5 to your computer and use it in GitHub Desktop.
measure3-webpack.prod.conf.js
module.exports = merge(baseWebpackConfig, {
// ...
plugins: [
// ...
// Build my bundle app.js from node_modules with NO quasar code
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
async: true,
minChunks: function (module, count) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
(
module.resource.indexOf('quasar') === -1 ||
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
)
}
}),
// Build my quasar.js bundle from node_modules with quasar code ONLY
new webpack.optimize.CommonsChunkPlugin({
name: 'quasar',
minChunks(module, count) {
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf('quasar') > -1
)
},
}),
// Find anything that is might be duplicated code and create a used-twice.js file with the code
// powerfull stuff right here.
new webpack.optimize.CommonsChunkPlugin({
name: 'used-twice',
async: false,
children: false,
minChunks: function (module, count) {
return count >= 2;
},
}),
// ...
]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment