Skip to content

Commit cf31a32

Browse files
committed
locale build fix
1 parent 8b3f5c8 commit cf31a32

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

modules/config/webpack.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,30 +253,41 @@ module.exports = function () {
253253
_: 'lodash'
254254
}),
255255

256-
// ignore all locales (will require manually from moment-with-locale
256+
// ignore all locales except current lang
257257
new webpack.IgnorePlugin({
258-
checkResource: (arg) => {
258+
checkResource(arg) {
259259
// locale requires that file back from it, need to keep it
260-
if (arg === '../moment') return false;
261-
tmp = arg;
260+
if (arg === '../moment') return false; // don't ignore this
261+
if (arg === './' + config.lang || arg === './' + config.lang + '.js') return false; // don't ignore current locale
262+
tmp = arg; // for logging only
262263
return true;
263264
},
264265
// under dirs like: ../locales/..
265-
checkContext: arg => {
266+
checkContext(arg) {
266267
let ignore = arg.endsWith(path.join('node_modules', 'moment', 'locale'));
267268
if (ignore) {
268-
//console.log("ignore moment locale", tmp, arg);
269+
// console.log("ignore moment locale", tmp, arg);
269270
return true;
270271
}
271272
}
272273
}),
273274

275+
274276
// ignore site locale files except the lang
275277
new webpack.IgnorePlugin({
276-
checkResource: (arg) => arg.endsWith('.yml') && arg !== './' + config.lang + '.yml',
278+
checkResource(arg) {
279+
let result = arg.endsWith('.yml') && !arg.endsWith('/' + config.lang + '.yml');
280+
tmp = arg; // for logging
281+
return result;
282+
},
277283
// under dirs like: ../locales/..
278-
checkContext: arg => /\/locales(\/|$)/.test(arg)
284+
checkContext(arg) {
285+
let ignore = /\/locales(\/|$)/.test(arg);
286+
// console.log("ignore yml", tmp, arg);
287+
return ignore;
288+
}
279289
}),
290+
280291

281292
new WriteVersionsPlugin(path.join(config.cacheRoot, 'webpack.versions.json')),
282293

0 commit comments

Comments
 (0)