-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (32 loc) · 1.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
/**
* merge and export
* @author ryan.bian
*/
const merge = require('webpack-merge');
const { PROJECT_ROOT } = require('./src/lib');
const _getBaseConfig = require('./src/base.conf');
const _getProdConfig = require('./src/prod.conf');
const _getDevConfig = require('./src/dev.conf');
const DEFAULT_PROJECT_CONFIG = require('./src/projectConfig');
const MERGE_STRATEGY = {
plugins: 'append',
};
exports.DEFAULT_PROJECT_CONFIG = DEFAULT_PROJECT_CONFIG;
exports.getProdConfig = async (PROJECT_CONFIG, options) => {
try {
const baseConfig = await _getBaseConfig(PROJECT_CONFIG, options);
const prodConfig = await _getProdConfig(PROJECT_CONFIG, options);
return merge.smartStrategy(MERGE_STRATEGY)(baseConfig, prodConfig);
} catch(e) {
throw Error(e);
}
};
exports.getDevConfig = async (PROJECT_CONFIG, options) => {
try {
const baseConfig = await _getBaseConfig(PROJECT_CONFIG, options);
const devConfig = await _getDevConfig(PROJECT_CONFIG, options);
return merge.smartStrategy(MERGE_STRATEGY)(baseConfig, devConfig);
} catch(e) {
throw Error(e);
}
};