Created
October 28, 2017 17:15
-
-
Save pablohpsilva/6c80f336b61914497a3063c5257286d5 to your computer and use it in GitHub Desktop.
measure3-webpack.prod.conf.js
This file contains 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
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