#335: configure webpack to allow usage of single source of supported languages (i18n/index.json)

This commit is contained in:
SleepWalker
2017-06-08 22:44:28 +03:00
parent a026ee3adf
commit 59000926ab
2 changed files with 19 additions and 34 deletions

View File

@@ -10,6 +10,7 @@ const CircularDependencyPlugin = require('circular-dependency-plugin');
const cssUrl = require('webpack-utils/cssUrl');
const cssImport = require('postcss-import');
const SUPPORTED_LANGUAGES = Object.keys(require('./src/i18n/index.json'));
const rootPath = path.resolve('./src');
const outputPath = path.join(__dirname, 'dist');
@@ -131,7 +132,12 @@ const webpackConfig = {
}),
new webpack.ProvidePlugin({
React: 'react'
})
}),
// restrict webpack import context, to create chunks only for supported locales
// @see services/i18n.js
new webpack.ContextReplacementPlugin(
/locale-data/, new RegExp('/(' + SUPPORTED_LANGUAGES.join('|') + ')\\.js')
)
],
module: {