This repository was archived by the owner on Apr 19, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathwebpack.prod.cjs
More file actions
64 lines (55 loc) · 1.83 KB
/
Copy pathwebpack.prod.cjs
File metadata and controls
64 lines (55 loc) · 1.83 KB
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
const webpack = require("webpack");
const path = require("path");
const fs = require("fs");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const ESLintPlugin = require("eslint-webpack-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("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)$/, // include .js files
use: [
{
loader: "babel-loader",
},
],
exclude: /node_modules/,
},
{
test: /\.(js|jsx|ts|tsx)$/, // include .js files
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(),
],
};
};