-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathwebpack.config.js
More file actions
27 lines (21 loc) · 814 Bytes
/
webpack.config.js
File metadata and controls
27 lines (21 loc) · 814 Bytes
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
const buildValidations = require('./build-utils/build-validations');
const commonConfig = require('./build-utils/webpack.common');
const argv = require('webpack-nano/argv');
const { merge } = require('webpack-merge');
const addons = (/* string | string[] */ addonsArg) => {
let addons = Array.isArray(addonsArg)
? addonsArg.filter((item) => item !== true)
: [addonsArg].filter(Boolean);
return addons.map((addonName) =>
require(`./build-utils/addons/webpack.${addonName}.js`)
);
};
module.exports = () => {
const { env, addons: addonsArg } = argv;
if (!env) {
throw new Error(buildValidations.ERR_NO_ENV_FLAG);
}
const envConfig = require(`./build-utils/webpack.${env}.js`);
const mergedConfig = merge(commonConfig, envConfig, ...addons(addonsArg));
return mergedConfig;
};