fix: build dist with locales (#4910)

This commit is contained in:
Wei Zhu 2017-02-17 09:36:42 +08:00 committed by Benjy Cui
parent df3617dded
commit 58afe5f729
2 changed files with 21 additions and 0 deletions

11
index-with-locales.js Normal file
View File

@ -0,0 +1,11 @@
const antd = require('./components');
const req = require.context('./components', true, /^\.\/locale-provider\/.+_.+\.tsx$/);
antd.locales = {};
req.keys().forEach((mod) => {
const match = mod.match(/\/([^/]+).tsx$/);
antd.locales[match[1]] = req(mod);
});
module.exports = antd;

View File

@ -18,12 +18,22 @@ function es3ify(webpackConfig) {
});
}
function addLocales(webpackConfig) {
let packageName = 'antd-with-locales';
if (webpackConfig.entry['antd.min']) {
packageName += '.min';
}
webpackConfig.entry[packageName] = './index-with-locales.js';
webpackConfig.output.filename = '[name].js';
}
module.exports = function (webpackConfig) {
webpackConfig = getWebpackConfig(webpackConfig);
if (process.env.RUN_ENV === 'PRODUCTION') {
webpackConfig.forEach((config) => {
es3ify(config);
ignoreMomentLocale(config);
addLocales(config);
});
}
return webpackConfig;