site: Add replaceLib plugin to babel

This commit is contained in:
Wei Zhu 2017-11-27 18:28:52 +08:00
parent ea338eb637
commit 143a7232e3

View File

@ -1,9 +1,20 @@
const path = require('path');
const CSSSplitWebpackPlugin = require('css-split-webpack-plugin').default;
const replaceLib = require('antd-tools/lib/replaceLib');
const isDev = process.env.NODE_ENV === 'development';
const usePreact = process.env.REACT_ENV === 'preact';
function alertBabelConfig(rules) {
rules.forEach((rule) => {
if (rule.loader && rule.loader === 'babel-loader') {
rule.options.plugins.push(replaceLib);
} else if (rule.use) {
alertBabelConfig(rule.use);
}
});
}
module.exports = {
port: 8001,
source: {
@ -80,6 +91,8 @@ module.exports = {
config.devtool = 'source-map';
}
alertBabelConfig(config.module.rules);
config.plugins.push(new CSSSplitWebpackPlugin({ size: 4000 }));
return config;