-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
98 lines (85 loc) · 2.12 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
const crypto = require("crypto");
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const isDevelopment = process.env.NODE_ENV === "development";
const stats = {
assetsSort: "chunks",
entrypoints: false,
excludeAssets: /\.map$/,
colors: true,
version: false,
hash: false,
timings: false,
cached: false,
cachedAssets: false,
chunkModules: false,
chunks: false,
entrypoints: false,
modules: false,
};
// If we have collisions, I'll eat my socks
const hashCode = (value) => {
return crypto.createHash("md5").update(value).digest("hex").slice(0, 12);
};
const mode = isDevelopment ? "development" : "production";
console.log(`Running webpack in ${mode} mode`);
console.log("Your CPU fan sounds kinda quiet. Lemme fix that...\n");
module.exports = {
mode,
devtool: "source-map",
stats,
devServer: {
publicPath: "/",
port: 3000,
hot: true,
inline: true,
contentBase: path.join(__dirname, "public"),
stats,
},
watchOptions: {
poll: true,
ignored: /node_modules/,
},
output: {
pathinfo: true,
filename: "static/js/[name].js",
sourceMapFilename: "static/maps/[file].map[query]",
chunkFilename: "static/js/[name].chunk.js",
globalObject: "this",
},
optimization: {
minimize: !isDevelopment,
splitChunks: {
chunks: "all",
name(_module, chunks, cacheGroupKey) {
const hashChunks = hashCode(chunks.join("-"));
return `${cacheGroupKey}-${hashChunks}`;
},
},
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
modules: [path.resolve(__dirname, "node_modules")],
},
module: {
strictExportPresence: true,
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: ["babel-loader", "ts-loader"],
},
{ test: /\.(glsl)$/, use: "raw-loader" },
],
},
plugins: [
!isDevelopment &&
new CopyWebpackPlugin({
patterns: [{ from: "public" }],
}),
new HtmlWebpackPlugin({
template: "./public/index.html",
}),
].filter(Boolean),
};