Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ...
let webpack = require("webpack");
mix.webpackConfig({
plugins: [
// Choose the language you want to keep (Ex: "fr")
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /fr/)
]
});
@rap2hpoutre

This comment has been minimized.

Copy link
Owner Author

commented Mar 15, 2017

Add this at the end of your webpack.mix.js. It will work only if you use momentJS (but it seems it's included every time in my projects, I don't know why btw)

Credit: http://stackoverflow.com/questions/25384360/how-to-prevent-moment-js-from-loading-locales-with-webpack

@jycr753

This comment has been minimized.

Copy link

commented Mar 15, 2017

Is there a way allow more than one language?

@vasilegoian

This comment has been minimized.

Copy link

commented Mar 16, 2017

For more than one language you can use regex. I haven't tested the code below, but it should work.

let webpack = require("webpack");
mix.webpackConfig({
    plugins: [
      // Choose the language you want to keep (Ex: "fr")
      new webpackContextReplacementPlugin(/moment[\\\/]locale$/, /^\.\/(fr|en)$/)
    ]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.