-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
60 lines (55 loc) · 1.69 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
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const webpack = require("webpack");
const CompressionPlugin = require("compression-webpack-plugin");
const production = process.env.NODE_ENV !== "development";
// eslint-disable-next-line no-console
console.log(`Mode: ${production ? "production" : "development"} ($NODE_ENV=${JSON.stringify(process.env.NODE_ENV)})`);
/** @type {webpack.Plugin[]} */
const plugins = [
new webpack.DefinePlugin({
DEBUG_APP: !production
})
];
if (production) {
// Compress scripts in production for smaller file size
plugins.push(new CompressionPlugin({
algorithm: "gzip",
cache: true
}));
}
/** @type {webpack.Configuration} */
module.exports = {
devtool: production ? undefined : "inline-source-map",
entry: {
account: "./src/public/scripts/account.ts",
document: "./src/public/scripts/document.ts",
error: "./src/public/scripts/error.ts",
group: "./src/public/scripts/group.ts",
home: "./src/public/scripts/home.ts",
login: "./src/public/scripts/login.ts",
testing: "./src/public/scripts/testing.ts"
},
mode: production ? "production" : "development",
module: {
rules: [
{
exclude: /node_modules/,
test: /\.tsx?$/,
use: "ts-loader"
},
{
test: /\.txt$/i,
use: "raw-loader"
}
]
},
output: {
filename: "[name]_bundle.js",
path: path.resolve(__dirname, "dist", "public", "scripts")
},
plugins,
resolve: {
extensions: [ ".tsx", ".ts", ".js" ]
}
};