-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.production.js
70 lines (62 loc) · 2.08 KB
/
webpack.production.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
/* eslint-disable @typescript-eslint/no-var-requires */
const webpack = require("webpack");
const path = require("path");
const fs = require("fs");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCssAssetsPlugin = require("optimize-css-assets-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 = (env) => {
return {
mode: env.mode,
module: {
rules: [{
enforce: "pre",
test: /\.(js|jsx|ts|tsx)$/,
exclude: /node_modules/,
loader: "eslint-loader",
options: {
emitError: true,
emitWarning: true,
failOnError: true,
failOnWarning: true,
},
},
{
test: /\.(js|jsx|ts|tsx)$/,
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",
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
}),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.css$/i,
cssProcessor: require("cssnano"),
cssProcessorPluginOptions: {
preset: ["default", {
discardComments: {
removeAll: true
}
}],
},
canPrint: true,
}),
new webpack.ProgressPlugin(),
],
};
};