not leave require locale in dist files, close #3204

This commit is contained in:
afc163 2016-10-08 16:12:19 +08:00
parent a987e34f6f
commit d063ed4dca

View File

@ -1,5 +1,11 @@
const webpack = require('webpack');
const getWebpackConfig = require('antd-tools/lib/getWebpackConfig');
function ignoreMomentLocale(webpackConfig) {
delete webpackConfig.module.noParse;
webpackConfig.plugins.push(new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/));
}
module.exports = function (webpackConfig) {
webpackConfig = getWebpackConfig(webpackConfig);
if (process.env.RUN_ENV === 'PRODUCTION') {
@ -8,6 +14,11 @@ module.exports = function (webpackConfig) {
test: /\.(tsx|jsx?)$/,
loader: 'es3ify-loader',
});
// noParse still leave `require('./locale' + name)` in dist files
// ignore is better
// http://stackoverflow.com/q/25384360
ignoreMomentLocale(webpackConfig[0]);
ignoreMomentLocale(webpackConfig[1]);
}
return webpackConfig;
};