I would like to load 2 locales en-gb
and fr-ch
only from Moment.js , then assign the moment
class to the scopewindow
to use the library everywhere in my Vuejs components.
Currently, my app.js
has this require line:
window.moment = require('moment')
I am suspecting it can be accomplished thanks to the solutions here (adding IgnorePlugin and ContextReplacementPlugin to webpack.config.js
):
plugins.push(new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en-gb|fr-ch/))
module.exports.plugins = plugins;
OR
plugins.push(new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/))
module.exports.plugins = plugins;
Where should you add these pieces of code (webpack.config.js
and/or app.js
and/or webpack.mix.js
) to ignore all other locales when importing momentjs
?