Skip to content

Commit

Permalink
fix: build dist with locales (ant-design#4910)
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck authored and benjycui committed Feb 17, 2017
1 parent df3617d commit 58afe5f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions index-with-locales.js
Original file line number Diff line number Diff line change
@@ -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 changes: 10 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 58afe5f

Please sign in to comment.