mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-26 16:52:06 +05:30
Исправлен билд для поддержки загрузки флагов из npm пакета
This commit is contained in:
parent
ba6e997f65
commit
ed539917d4
@ -99,4 +99,3 @@ const localeToCountryCode = {
|
||||
export function requireLocaleFlag(locale: string) {
|
||||
return require(`flag-icon-css/flags/4x3/${localeToCountryCode[locale] || locale}.svg`);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,18 @@ const outputPath = path.join(__dirname, 'dist');
|
||||
|
||||
const packageJson = require('./package.json');
|
||||
|
||||
var config = {};
|
||||
const localeToCountryCode = {
|
||||
en: 'gb',
|
||||
be: 'by',
|
||||
pt: 'br',
|
||||
uk: 'ua',
|
||||
vi: 'vn',
|
||||
sl: 'si',
|
||||
};
|
||||
|
||||
const flagsList = SUPPORTED_LANGUAGES.map((locale) => localeToCountryCode[locale] || locale);
|
||||
|
||||
let config = {};
|
||||
try {
|
||||
config = require('./config/env.js');
|
||||
} catch (err) {
|
||||
@ -135,8 +146,12 @@ const webpackConfig = {
|
||||
// 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')
|
||||
)
|
||||
/locale-data/, new RegExp(`/(${SUPPORTED_LANGUAGES.join('|')})\\.js`)
|
||||
),
|
||||
// @see functions.js:requireLocaleFlag()
|
||||
new webpack.ContextReplacementPlugin(
|
||||
/flag-icon-css\/flags\/4x3/, new RegExp(`/(${flagsList.join('|')})\\.svg`)
|
||||
),
|
||||
],
|
||||
|
||||
module: {
|
||||
@ -256,7 +271,12 @@ if (isProduction) {
|
||||
|
||||
webpackConfig.devtool = false;
|
||||
|
||||
webpackConfig.entry.vendor = Object.keys(packageJson.dependencies);
|
||||
const ignoredPlugins = [
|
||||
'flag-icon-css',
|
||||
];
|
||||
|
||||
webpackConfig.entry.vendor = Object.keys(packageJson.dependencies)
|
||||
.filter((module) => ignoredPlugins.indexOf(module) === -1);
|
||||
} else {
|
||||
webpackConfig.plugins.push(
|
||||
new webpack.DllReferencePlugin({
|
||||
|
Loading…
Reference in New Issue
Block a user