-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.ts
76 lines (75 loc) · 2.13 KB
/
webpack.config.ts
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
import copyWebpackPlugin from "copy-webpack-plugin";
import eslintPlugin from "eslint-webpack-plugin";
import htmlWebpackPlugin from "html-webpack-plugin";
import path from "path";
import type webpack from "webpack";
import type { Configuration as WebpackDevServerConfiguration } from "webpack-dev-server";
export default (env: any): webpack.Configuration & { devServer?: WebpackDevServerConfiguration } => ({
entry: "./src/index.ts",
output: {
path: path.join(__dirname, "/dist"),
filename: "[name].bundle.js",
clean: true
},
optimization: {
minimize: env.production
},
cache: true,
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader"
},
{
test: /\.html$/,
loader: "html-loader"
}
]
},
resolve: {
alias: {
// eslint-disable-next-line @typescript-eslint/naming-convention
"@": path.resolve(__dirname, "src")
},
modules: ["src", "node_modules"],
extensions: [".js", ".jsx", ".ts", ".tsx"],
fallback: {
"fs": false,
"path": false
}
},
plugins: [
new htmlWebpackPlugin({
template: "./src/index.html"
}),
new eslintPlugin({
extensions: ["ts", "tsx"],
fix: true,
cache: true
}),
new copyWebpackPlugin({
patterns: [
{ from: "res", to: "res" }
]
})
],
devServer: {
host: "0.0.0.0",
port: 20310,
allowedHosts: "all",
client: {
logging: "none"
},
hot: true,
watchFiles: ["src/**/*"],
server: "https",
headers: {
// eslint-disable-next-line @typescript-eslint/naming-convention
"Cross-Origin-Opener-Policy": "same-origin",
// eslint-disable-next-line @typescript-eslint/naming-convention
"Cross-Origin-Embedder-Policy": "require-corp"
}
},
mode: env.production ? "production" : "development"
});