-
Notifications
You must be signed in to change notification settings - Fork 29
/
webpack.prod.ts
65 lines (56 loc) · 1.83 KB
/
webpack.prod.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
import * as webpack from "webpack";
import * as path from "path";
import fs from "fs";
import MiniCssExtractPlugin from "mini-css-extract-plugin";
import ESLintPlugin from "eslint-webpack-plugin";
import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
import TerserPlugin from "terser-webpack-plugin";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf-8"));
module.exports = () => {
return {
mode: "production",
module: {
rules: [
{
// test: /\.(js|jsx|ts|tsx)$/,
test: /\.(ts|tsx)$/, //temp fix for imports in config.js
use: [
{
loader: "babel-loader",
},
],
exclude: /node_modules/,
},
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
],
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "game.[contenthash].js",
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin(), new CssMinimizerPlugin()],
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(pkg.version + "-r"),
}),
new ESLintPlugin({
emitError: true,
emitWarning: true,
failOnError: true,
failOnWarning: true,
}),
new webpack.ProgressPlugin(),
],
};
};