-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathwebpack.config.js
More file actions
33 lines (27 loc) · 963 Bytes
/
webpack.config.js
File metadata and controls
33 lines (27 loc) · 963 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
29
30
31
32
33
const webpackMerge = require('webpack-merge');
// const CleanWebpackPlugin = require('clean-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const buildValidations = require('./build/webpack/buildValidations.js');
const commonConfig = require('./build/webpack/webpack.common.js');
// 'env' will contain the environment variable from 'scripts'
// section in 'package.json'.
module.exports = env => {
// We use 'buildValidations' to check for the 'env' flag
if (!env) {
throw new Error(buildValidations.ERR_NO_ENV_FLAG);
}
// Select which Webpack configuration to use; development
// or production
const envConfig = require(`./build/webpack/webpack.${env.env}.js`);
const mergedConfig = webpackMerge(
commonConfig,
envConfig,
{
plugins: [
new CleanWebpackPlugin({ verbose: true }),
]
}
);
// Then return the final configuration for Webpack
return mergedConfig;
};