jmblog / how-to-optimize-momentjs-with-webpack

Explaining how to optimize the large bundle size of moment.js with webpack
678 stars 20 forks source link

optimize momentjs #11

Open akshata456 opened 4 years ago

akshata456 commented 4 years ago

Here i used moment :^2.24.0 I want to use specific locals in my code .I used this solution const webpack = require('webpack'); module.exports = { //... plugins: [ // load moment/locale/ja.js and moment/locale/it.js new webpack.ContextReplacementPlugin(/moment[/\]locale$/, /ja|it/), ], }; It didn't work for me , it still load other locals also.Please check.Thanks.

jmblog commented 4 years ago

Hi @akshata456,

Can you try to change your webpack config as below?

- new webpack.ContextReplacementPlugin(/moment[/\]locale$/, /ja|it/),
+ new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /ja|it/),