forked from easy-team/easywebpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (44 loc) · 2.08 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
'use strict';
const WebpackTool = require('webpack-tool');
exports.WebpackTool = WebpackTool;
exports.webpack = WebpackTool.webpack;
exports.merge = WebpackTool.merge;
exports.Utils = require('./utils/utils');
exports.WebpackBuilder = require('./lib/builder');
exports.WebpackBaseBuilder = require('./lib/target/base');
exports.WebpackClientBuilder = require('./lib/target/client');
exports.WebpackServerBuilder = require('./lib/target/server');
exports.WebpackDllBuilder = require('./lib/target/dll');
exports.getConfig = (config = {}, option = {}) => {
return exports.WebpackBuilder.getConfig(config, option);
};
exports.getWebpackConfig = (config = {}, option = {}) => {
if (config.framework === 'dll' || option.onlyDll) {
return exports.getDllWebpackConfig(config, option);
}
if (config.framework === 'js' || config.framework === 'web' || config.target === 'web' || option.onlyWeb) {
return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackClientBuilder]);
}
if (config.framework === 'node' || config.target === 'node' || option.onlyNode) {
return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackServerBuilder]);
}
return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackClientBuilder, exports.WebpackServerBuilder], option);
};
exports.getWebWebpackConfig = (config = {}, option = {}) => {
return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackClientBuilder], option);
};
exports.getNodeWebpackConfig = (config = {}, option = {}) => {
return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackServerBuilder], option);
};
exports.getDllWebpackConfig = (config = {}, option = {}) => {
if (option.singleConfig) {
return new exports.WebpackDllBuilder(config).create();
}
return exports.WebpackBuilder.getDllWebpackConfig(config);
};
exports.build = (webpackConfig, config, callback) => {
return new WebpackTool(config).build(webpackConfig, config, callback);
};
exports.server = (webpackConfig, config, callback) => {
return new WebpackTool(config).server(webpackConfig, config, callback);
};