-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
61 lines (50 loc) · 1.7 KB
/
index.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
'use strict';
var path = require('path');
var HappyPack = require('happypack');
var es6Config = require('ykit-config-es6');
exports.config = function(options, cwd) {
var originModifyQuery = options.modifyQuery;
options.modifyQuery = function(defaultQuery) {
defaultQuery.presets.push('react');
if (typeof originModifyQuery === 'function') {
return originModifyQuery(defaultQuery);
} else {
return defaultQuery;
}
};
es6Config.config.call(this, options, cwd);
extend(true, this.config, {
plugins: this.config.plugins.concat([
new this.webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(
this.env === 'prd' || this.env === 'beta'
? 'production'
: 'dev'
)
}
})
])
});
if (options.ie8) {
var pkg = require(path.join(cwd, 'package.json'));
var reactVer = pkg.dependencies.react;
var reactDomVer = pkg.dependencies['react-dom'];
if (!reactVer || reactVer.search(/\^?0\./) === -1) {
console.log('兼容 ie8 需要手动安装 react@0.14.8');
process.exit(0);
}
if (!reactDomVer || reactDomVer.search(/\^?0\./) === -1) {
console.log('兼容 ie8 需要手动安装 react-dom@0.14.8');
process.exit(0);
}
this.config.module.postLoaders.push({
test: /\.(js|jsx)$/,
loader: 'es3ify-loader'
});
}
this.commands.push({
name: 'setup',
module: require('./commands/setup.js')
});
};