-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
53 lines (47 loc) · 1.25 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
51
52
53
const path = require("path")
const webpack = require("webpack");
const { merge } = require("webpack-merge")
const parts = require("./webpack.parts")
const paths = require("./config/paths")
const getClientEnvironment = require('./config/env')
const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1));
const commonConfig = merge([
{
entry: ["./src"],
output: {
path: path.join(__dirname, "dist"),
filename: "[name].js",
publicPath: "/"
},
resolve: {
alias: {
'@': path.resolve('src')
}
},
plugins: [
new webpack.DefinePlugin(env.stringified)
]
},
parts.loadJavaScript(),
parts.page(),
parts.loadLess(),
parts.loadCSS(),
parts.loadPic(),
])
const productionConfig = merge([]);
const developmentConfig = merge([
parts.devServer()
])
const getConfig = (mode) => {
switch (mode) {
case "production":
return merge(commonConfig, productionConfig, { mode });
case "development":
return merge(commonConfig, developmentConfig, { mode });
case "test":
return merge(commonConfig, developmentConfig, { mode: 'none' })
default:
throw new Error(`Trying to use an unknown mode, ${ mode }`);
}
}
module.exports = getConfig(process.env.NODE_ENV);