diff --git a/webpack.config.js b/webpack.config.js index e387e0c16f..d6646d9e19 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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; };