diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index 0bf8a23..8bf8e73 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -16,17 +16,6 @@ const UglifyJsPlugin = require('uglifyjs-webpack-plugin') const env = require('../config/prod.env') -// List available locales, to fetch only the required locales from Moment.JS: -// Build a regexp that selects the locale's name without the JS extension (due -// to the way moment includes those) and ensure that's the last character to -// not include locale variants. See discussion in -// https://framagit.org/bnjbvr/kresus/merge_requests/448#note_130514 -const locales = fs.readdirSync('src/i18n').filter(x => x != 'index.js').map( - x => x.replace('.js', '') -); -const localesRegex = new RegExp( - '(' + locales.join('|') + ')$' -); const webpackConfig = merge(baseWebpackConfig, { module: { @@ -140,7 +129,7 @@ const webpackConfig = merge(baseWebpackConfig, { }), // Only keep the useful locales from Moment. - new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, localesRegex), + new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), // copy custom static assets new CopyWebpackPlugin([ diff --git a/src/i18n/index.js b/src/i18n/index.js index 0ff5512..8d9f3b5 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -1,10 +1,16 @@ import Vue from 'vue'; import VueI18n from 'vue-i18n'; +// Moment locales +import 'moment/locale/en-gb'; +import 'moment/locale/fr'; + +// App locales import en from './en.json'; import fr from './fr.json'; import oc from './oc.json'; +// Local moment locales import './moment/oc'; export const AVAILABLE_LOCALES = [