mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 12:39:49 +08:00
fix: build dist with locales (#4910)
This commit is contained in:
parent
df3617dded
commit
58afe5f729
11
index-with-locales.js
Normal file
11
index-with-locales.js
Normal 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;
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user