forked from stylescape/stylescape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
50 lines (38 loc) · 1.76 KB
/
webpack.config.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
// webpack.config.js
// ============================================================================
// Imports
// ============================================================================
import { merge } from "webpack-merge";
import configCommon from "./webpack.common.js";
import configDevelopment from "./webpack.dev.js";
import configProduction from "./webpack.prod.js";
// ============================================================================
// Constants
// ============================================================================
/**
* Merge Webpack Configuration
*
* Merges the common configuration with environment-specific configurations
* based on the build mode (development or production).
*
* @param {object} env - The environment variables passed to the Webpack configuration.
* @param {object} args - Arguments and options passed via the command line or scripts.
* @return {object} - The merged Webpack configuration object.
* @throws {Error} - Throws an error if an invalid build mode is specified.
*/
const config = (env, args) => {
switch (args.mode) {
case "development":
console.info("Merging common configuration with development settings...");
return merge(configCommon, configDevelopment);
case "production":
console.info("Merging common configuration with production settings...");
return merge(configCommon, configProduction);
default:
throw new Error("No matching configuration was found! Please specify 'development' or 'production' mode.");
}
};
// ============================================================================
// Exports
// ============================================================================
export default config