-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
71 lines (71 loc) · 1.53 KB
/
webpack.config.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
71
const path = require("path"),
TerserPlugin = require("terser-webpack-plugin"),
fs = require('fs');
const babelLoader = {
loader: "babel-loader",
options: {
cacheDirectory: true,
presets: ["@babel/preset-env"],
cacheDirectory: true,
compact: false,
},
};
const _is_prod = process.env.NODE_ENV === 'prod';
module.exports = {
plugins: [],
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [babelLoader, { loader: "ts-loader" }],
},
{ test: /\.js$/, exclude: /node_modules/, use: babelLoader },
],
},
resolve: { extensions: [".ts", ".js"] },
entry: {
'vr': path.join(__dirname, "./src/main.ts"),
},
output: {
filename: _is_prod ? "[name].prod.js" : "[name].dev.js",
path: _is_prod ? path.resolve(__dirname, "./dist") : path.resolve(__dirname, "./example"),
publicPath: 'dist/',
libraryTarget: 'umd',
globalObject: 'this',
chunkFilename: '[name].chunk.js'
},
devServer: {
contentBase: path.join(__dirname, 'example'),
index: 'index.html',
port: 3000,
open: true,
compress: true
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
terserOptions: {
ecma: 5,
warnings: false,
compress: { toplevel: true, passes: 2 },
mangle: { toplevel: true },
module: false,
output: {
comments: false
},
toplevel: false,
nameCache: null,
ie8: false,
keep_classnames: void 0,
keep_fnames: false,
safari10: false
},
extractComments: false
}),
],
},
};