-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.ts
94 lines (92 loc) · 2.73 KB
/
webpack.config.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
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
/* eslint-disable @typescript-eslint/naming-convention */
import ESLintPlugin from "eslint-webpack-plugin";
import HtmlWebpackPlugin from "html-webpack-plugin";
import path from "path";
import TerserPlugin from "terser-webpack-plugin";
import minifyPrivatesTransformer from "ts-transformer-minify-privates";
import type { Program } from "typescript";
import type { Configuration } from "webpack";
//import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
//const propertiesRenameTransformer = require('ts-transformer-properties-rename').default;
const config: Configuration & { devServer?: any } = {
entry: "./test/test_project/index.ts",
output: {
path: path.join(__dirname, "/testbundle"),
filename: "[name].bundle.js",
assetModuleFilename: "images/[name][ext]"
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: false,
output: {
beautify: true
},
mangle: {
keep_fnames: true,
keep_classnames: true,
properties: {
regex: /^_private_/
}
},
nameCache: {}
}
})
]
// splitChunks: {
// chunks: "all",
// },
},
module: {
rules: [{
test: /\.tsx?$/,
loader: "ts-loader",
options: {
configFile: "tsconfig.webpack.json",
getCustomTransformers: (program: Program) => ({
before: [
minifyPrivatesTransformer(program)
//propertiesRenameTransformer(program, { entrySourceFiles: ["./index.ts"] })
]
})
}
},
{
test: /\.(png|jpg|gif)$/,
type: "asset"
}
]
},
resolve: {
modules: [path.join(__dirname, "src"), "node_modules"],
extensions: [".ts", ".js"],
alias: {
"@src": path.join(__dirname, "src")
}
},
plugins: [
new HtmlWebpackPlugin({
template: "./test/test_project/index.html"
}),
new ESLintPlugin({
extensions: ["ts"],
cache: true,
fix: true
})
//new BundleAnalyzerPlugin()
],
devServer: {
host: "0.0.0.0",
port: 20310,
allowedHosts: [
"nonamehome.iptime.org"
],
client: {
logging: "none"
}
},
mode: "development"
};
export default config;