提交 a7821093 authored 作者: vipcxj's avatar vipcxj

1.generate a webpack config file for ide.

2.update antd to 3.x
上级 eaa3190c
......@@ -14,3 +14,4 @@ npm-debug.log*
/storybook-static
jsCodeStructure.html
/webpack
......@@ -13,7 +13,7 @@
"install-node": "6.9.2"
},
"dependencies": {
"antd": "^2.13.11",
"antd": "^3.3.0",
"axo": "0.0.2",
"bowser": "^1.8.1",
"dva": "^2.2.0-beta.2",
......
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
/* eslint-disable no-param-reassign */
const path = require('path');
const omit = require('lodash/omit');
const isFunction = require('lodash/isFunction');
const isUndefined = require('lodash/isUndefined');
const isObject = require('lodash/isObject');
const isEmpty = require('lodash/isEmpty');
const isArray = require('lodash/isArray');
const iteratee = require('lodash/iteratee');
const flatten = require('lodash/flatten');
const includes = require('lodash/includes');
const transform = require('lodash/transform');
const inspect = require('util').inspect;
const writeFileSync = require('fs').writeFileSync;
function pickDeep(collection, ...args) {
let predicate = args[0];
if (isFunction(predicate)) {
predicate = iteratee(predicate);
} else {
const keys = flatten(args);
predicate = (val, key) => {
return includes(keys, key);
};
}
return transform(collection, (memo, val, key) => {
let include = predicate(val, key);
if (include && (isObject(val) || isArray(val))) {
val = pickDeep(val, predicate);
include = !isEmpty(val);
}
if (include) {
if (isArray(collection)) {
memo.push(val);
} else {
memo[key] = val;
}
}
});
}
module.exports = function webpack(config) {
console.log(config);
config.module.rules.push({
test: /\.ejs$/,
loader: 'ejs-loader',
});
// config.plugins.push(
// new LodashModuleReplacementPlugin(),
// );
let cleanedConfig = omit(config, 'plugins');
cleanedConfig.resolve = omit(cleanedConfig.resolve, 'plugins');
cleanedConfig = pickDeep(cleanedConfig, v => !isFunction(v) && !isUndefined(v));
writeFileSync(path.resolve(__dirname, 'webpack/webpack.config.js'), `module.exports = ${inspect(cleanedConfig, false, null)};`);
return config;
};
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论