-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
133 lines (132 loc) · 3.57 KB
/
webpack.config.js
File metadata and controls
133 lines (132 loc) · 3.57 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const path = require("path");
const webpack = require("webpack");
const DefinePlugin = require("webpack").DefinePlugin;
const CaseSensitivePathsPlugin = require("case-sensitive-paths-webpack-plugin");
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
module.exports = {
mode: "development", // development production
context: path.resolve(__dirname),
output: {
path: path.resolve(__dirname, "dist"),
filename: "webclient-store.js",
library: "webclient-store",
libraryTarget: "umd",
libraryExport: "default",
},
entry: {
index: ["./src/index.ts"],
},
devtool: "inline-source-map",
resolve: {
extensions: [".ts"],
},
module: {
rules: [
{
test: /\.ts$/,
use: [
/* config.module.rule('ts').use('cache-loader') */
{
loader: "cache-loader",
options: {
cacheDirectory: path.resolve(
__dirname,
"node_modules",
".cache",
"ts-loader"
),
cacheIdentifier: "56acfc0d",
},
},
/* config.module.rule('ts').use('thread-loader') */
{
loader: "thread-loader",
},
/* config.module.rule('ts').use('babel-loader') */
{
loader: "babel-loader",
},
/* config.module.rule('ts').use('ts-loader') */
{
loader: "ts-loader",
options: {
transpileOnly: true,
happyPackMode: true,
allowTsInNodeModules: true,
},
},
],
},
],
},
optimization: {
minimizer: [
new TerserPlugin({
test: /\.js(\?.*)?$/i,
warningsFilter: () => true,
extractComments: false,
sourceMap: false,
cache: true,
cacheKeys: (defaultCacheKeys) => defaultCacheKeys,
parallel: true,
include: undefined,
exclude: undefined,
minify: undefined,
terserOptions: {
output: {
comments: /^\**!|@preserve|@license|@cc_on/i,
},
compress: {
arrows: false,
collapse_vars: false,
comparisons: false,
computed_props: false,
hoist_funs: false,
hoist_props: false,
hoist_vars: false,
inline: false,
loops: false,
negate_iife: false,
properties: false,
reduce_funcs: false,
reduce_vars: false,
switches: false,
toplevel: false,
typeofs: false,
booleans: true,
if_return: true,
sequences: true,
unused: true,
conditionals: true,
dead_code: true,
evaluate: true,
},
mangle: {
safari10: true,
},
},
}),
new UglifyJsPlugin(),
],
},
plugins: [
new BundleAnalyzerPlugin({ analyzerPort: 8919 }), //依赖图
/* config.plugin('define') */
new DefinePlugin({
"process.env": {
NODE_ENV: '"production"',
BASE_URL: '"/"',
},
}),
new CaseSensitivePathsPlugin(),
/* config.plugin('fork-ts-checker') */
new ForkTsCheckerWebpackPlugin({
tslint: true,
formatter: "codeframe",
checkSyntacticErrors: true,
}),
],
};