-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
webpack.config.js
108 lines (98 loc) · 2 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
let mode;
let resolveModules;
const rules = [
{
test: /\.ts$/,
use: ["ts-loader"]
}
];
const plugins = [];
if (process.env.NODE_ENV === "production") {
mode = "production";
resolveModules = ["node_modules", "dce-output", "src"];
rules.push({
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader",
options: { importLoaders: 1 }
},
"postcss-loader"
]
})
});
plugins.push(
new ExtractTextPlugin({
filename: "[name].css",
allChunks: true
})
);
} else {
mode = "development";
resolveModules = ["node_modules", "output", "src"];
rules.push({
test: /\.css$/,
use: [
"style-loader",
{
loader: "css-loader",
options: { importLoaders: 1 }
},
"postcss-loader"
]
});
}
console.warn("------------------------------------------");
console.warn("webpack running in mode: ", mode);
console.warn("------------------------------------------");
module.exports = {
context: __dirname,
mode,
target: "web",
entry: {
Home: ["./src/common.ts", "./src/HomePage.ts"],
Talk: ["./src/common.ts", "./src/TalkPage.ts"],
Search: ["./src/common.ts", "./src/SearchPage.ts"]
},
output: {
path: __dirname + "/../backend/dist",
filename: "[name].js",
publicPath: "/"
},
resolve: {
modules: resolveModules,
extensions: [".js", ".ts"]
},
module: {
rules
},
plugins,
optimization: {
splitChunks: {
cacheGroups: {
common: {
name: "common",
chunks: "initial",
minChunks: 3
}
}
}
},
devServer: {
host: "0.0.0.0",
historyApiFallback: true,
proxy: {
"/api": {
target: "http://localhost:3001",
secure: false,
pathRewrite: {
"^/api": ""
}
}
}
}
};