3

I'm using webpack to create output bundles for an angular2 project. I'm creating two bundles containing project codes and vendors:

entry: {
    main: './src/main',
    vendors: ['./node_modules/@angular/core', './node_modules/moment']
},
module: {
    loaders: [{
        test: /\.js$/,
        exclude: [nodeModulesDir],
        loader: 'babel'
    }]
},

With a brief book into vendors bundle, I see all the locale files of moment are included in vendor bundle, but I need just de_DE. how can I exclude unnecessary locales?

Reyraa
  • 4,174
  • 2
  • 28
  • 54
  • @FarzadYZ I've just defined the `vendors` entry point and `webpack` is importing them, since they're required somewhere in moment. – Reyraa Feb 10 '17 at 09:58
  • Possible duplicate of [How to prevent moment.js from loading locales with webpack?](http://stackoverflow.com/questions/25384360/how-to-prevent-moment-js-from-loading-locales-with-webpack) – Farzad Yousefzadeh Feb 10 '17 at 09:59
  • @FarzadYZ Great! Thank you – Reyraa Feb 10 '17 at 10:00

1 Answers1

2

Perhaps this could help

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

Create react app configs contain this too

new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
Roshana Pitigala
  • 8,437
  • 8
  • 49
  • 80
sahara18
  • 36
  • 5