forked from doppelmutzi/react-performance-strategies
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
28 lines (22 loc) · 773 Bytes
/
webpack.config.js
File metadata and controls
28 lines (22 loc) · 773 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
28
const buildValidations = require("./build-utils/build-validations");
const commonConfig = require("./build-utils/webpack.common");
const webpackMerge = require("webpack-merge");
const addons = (/* string | string[] */ addonsArg) => {
let addons = [...[addonsArg]] // Normalize array of addons (flatten)
.filter(Boolean); // If addons is undefined, filter it out
return addons.map((addonName) =>
require(`./build-utils/addons/webpack.${addonName}.js`)
);
};
module.exports = (env) => {
if (!env) {
throw new Error(buildValidations.ERR_NO_ENV_FLAG);
}
const envConfig = require(`./build-utils/webpack.${env.env}.js`);
const mergedConfig = webpackMerge(
commonConfig,
envConfig,
...addons(env.addons)
);
return mergedConfig;
};