-
Notifications
You must be signed in to change notification settings - Fork 3
/
ykit.js
84 lines (80 loc) · 2.44 KB
/
ykit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const path = require('path');
const envParam = require('./envParam.js');
module.exports = {
plugins: ['react'],
config: {
exports: [
['babel-polyfill', './scripts/index.js'],
['babel-polyfill', './scripts/login.js'],
],
modifyWebpackConfig(baseConfig) {
const envData = envParam[this.env];
baseConfig.plugins.push(new this.webpack.DefinePlugin({
ENV_CONFIG: JSON.stringify(envData),
}));
baseConfig.resolve.alias = {
COMPONENT: '/src/scripts/component',
CONST: '/src/scripts/const',
PAGE: '/src/scripts/page',
ROUTER: '/src/scripts/router',
STORE: '/src/scripts/store',
UTIL: '/src/scripts/util',
};
// 剔除依赖库 CDN引入
baseConfig.externals = {
react: 'React',
'react-dom': 'ReactDOM',
// 'antd': 'antd',
// 'moment': 'moment'
};
baseConfig.module.loaders = baseConfig.module.loaders.filter((loader) => {
if (loader.test.toString()
.match(/(css|less)/)) {
return false;
}
return true;
});
baseConfig.module.loaders.push({
test: /.css$/,
loader: 'style-loader!css-loader',
include: [
path.join(__dirname, './src/styles'),
],
}, {
test: /\.json$/,
loader: 'json-loader',
}, {
test: /.css$/,
loader: 'style-loader!css-loader?modules&localIdentName=[name]__[local]-[hash:base64:5]',
include: [
path.join(__dirname, './src/scripts'),
],
}, {
test: /.less$/,
include: [
path.join(__dirname, './src/styles'),
path.join(__dirname, './src/scripts'),
],
loader: 'style-loader!css-loader!less-loader',
});
return baseConfig;
},
commonsChunk: {
minChunks: 2, // 公共模块被使用的最小次数。比如配置为3,也就是同一个模块只有被3个以外的页面同时引用时才会被提取出来作为common chunks,默认为2
vendors: { // vendors是一个处理第三方库的配置项,结构是一个key,value数组,key是chunkname,value是第三方类库数组
lib: ['babel-polyfill',
'react',
'react-router',
'mobx',
'antd',
'axios',
'jsonp',
'promise-polyfill',
],
},
},
server: {
hot: true,
},
},
};