0👍
According to this thread on Github pointed by the official documentation: https://github.com/moment/moment/issues/2373
You could try like ldrick
answer:
These are the relevant parts in my webpack.config.js.
const path = require("path");
const webpack = require("webpack");
module.exports = () => {
return {
// ...
resolve: {
// Use src Moment.js to be optimized and packed.
alias: {
moment$: "moment/src/moment",
},
},
// ...
plugins: [
// Switch context for Moment.js locales.
new webpack.ContextReplacementPlugin(/^\.\/locale$/, context => {
// Don't touch anything else then "moment".
if (!/\/moment\//.test(context.context)) {
return;
}
// Working with "moment/src/moment" instead of "moment" requires
// redirecting "./locale" back to "../../locale".
Object.assign(context, {
// Want all locales, enable this line.
// regExp: /^\.\/\w+/,
// Just use some locales, enable this line.
// regExp: /de|fr|hu/,
// Don't use any locales except default "en".
regExp: undefined,
request: "../../locale",
});
}),
// ...
],
// ...
};
};
Or try instead of new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
this expression (it seems to be the work to not importing the locates files on building):
new webpack.ContextReplacementPlugin(
/moment[\/\\]locale$/,
/en|de|fr|es|pl|ua|ru/
),
(change the langs according what you are using).
Hope it helps or at least give you some light!
- [Vuejs]-Why does Jest throw an error on dynamic import() when calculating coverage for a Vue.js app?
Source:stackexchange.com