Browse Source

fix: build dist with locales (#4910)

pull/4917/head
Wei Zhu 8 years ago
committed by Benjy Cui
parent
commit
58afe5f729
  1. 11
      index-with-locales.js
  2. 10
      webpack.config.js

11
index-with-locales.js

@ -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;

10
webpack.config.js

@ -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…
Cancel
Save