moment.js被全量打包

使用webpack打包moment.js的时候,会将moment.js所有的locale全部打包进去,超级大,请问怎么只打包自己需要的部分?

阅读 11.4k
1 个回答
// new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /zh-cn/),
// new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),

任选其一,另外,推荐使用 date-fns

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题