-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
57 lines (53 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
54
55
56
57
const path = require("path")
const merge = require("webpack-merge")
const parts = require("./webpack/parts.config")
const productionConfig = require("./webpack/prod.config")
const developmentConfig = require("./webpack/dev.config")
APP_ENTRY = path.join(__dirname, "client")
APP_OUTPUT = path.join(__dirname, "public")
const baseConfig = {
entry: ["babel-polyfill", APP_ENTRY],
output: {
path: APP_OUTPUT,
publicPath: '/public/',
filename: "bundle.js"
},
module: {
rules: [
{
loader: "babel-loader",
exclude: /node_modules/,
test: /.jsx?$/,
query: {
presets: ["@babel/env", "@babel/react"],
plugins: ["@babel/proposal-class-properties"]
}
},
{
loader: "style-loader!css-loader",
test: /\.css$/
}
]
},
node: {
fs: "empty"
},
resolve: {
extensions: [".js", ".jsx", "*"]
}
}
const prodConfig = merge([productionConfig])
const devConfig = merge([
parts.devServer({
host: process.env.HOST,
port: process.env.PORT,
}),
developmentConfig
])
module.exports = mode => {
console.log(mode)
if (mode === "production") {
return merge(baseConfig, prodConfig, { mode })
}
return merge(baseConfig, devConfig, { mode })
}