admin管理员组文章数量:1425717
I am trying to exclude unused momentjs locales using webpack. I have tried both 3 ways below:
1- moment-locales-webpack-plugin
new MomentLocalesPlugin({
localesToKeep: ["en"]
})
2- ContextReplacementPlugin
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/)
3- ignorePlugin
new webpack.IgnorePlugin(
/^\.\/locale$/,
/moment$/
});
But, none of these methods work for me and all locales still exist in final bundle. My webpack version is 4.28.2. And I am using moment-js v 2.23.
I am trying to exclude unused momentjs locales using webpack. I have tried both 3 ways below:
1- moment-locales-webpack-plugin
new MomentLocalesPlugin({
localesToKeep: ["en"]
})
2- ContextReplacementPlugin
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/)
3- ignorePlugin
new webpack.IgnorePlugin(
/^\.\/locale$/,
/moment$/
});
But, none of these methods work for me and all locales still exist in final bundle. My webpack version is 4.28.2. And I am using moment-js v 2.23.
Share Improve this question asked Feb 20, 2019 at 14:38 Hadi RanjbarHadi Ranjbar 1,8124 gold badges24 silver badges44 bronze badges 2- Check this: github./moment/moment/issues/2517#issuement-393704231 – Prerak Sola Commented Feb 20, 2019 at 14:44
- @SergeK. That's my first solution. – Hadi Ranjbar Commented Feb 20, 2019 at 14:53
1 Answer
Reset to default 5new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/)
There is no 'en' locale in moment.js; that's why it loads all of them. Try /en-gb/
if you need only English.
本文标签: javascriptExclude unused locales momentjs using webpackStack Overflow
版权声明:本文标题:javascript - Exclude unused locales momentjs using webpack - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745424779a2658060.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论