-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.js
111 lines (109 loc) · 2.63 KB
/
webpack.prod.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
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
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const TerserPlugin = require('terser-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
// define preprocessor variables
const opts = {
DEVELOPMENT: false
};
module.exports = {
entry: {
main: "./src/index.ts"
},
output: {
path: path.resolve(__dirname, "./dist"),
// publicPath: path.resolve(__dirname, "./static"),
filename: "[name].bundle.js",
},
"watch": false,
"context": __dirname, // to automatically find tsconfig.json
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: "ts-loader",
"options": {
"transpileOnly": false, // Set to true if you are using fork-ts-checker-webpack-plugin
"projectReferences": true
}
}
],
exclude: /node_modules/,
},
],
},
resolve: {
modules: [
"node_modules",
path.resolve(__dirname)
],
alias: {
'~': path.resolve(__dirname, 'src/'),
},
plugins: [
new TsconfigPathsPlugin({})
],
extensions: [".tsx", ".ts", ".js"],
},
devServer: {
historyApiFallback: true,
contentBase: path.resolve(__dirname, "./dist"),
open: true,
hot: true,
host: 'localhost',
//0.0.0.0 //enable remote devices using http://IP_ADDRESS:8080
port: 8080,
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
//https://github.com/terser/terser#compress-options
//compress: false,
compress: {
collapse_vars: false,
keep_classnames: true,
keep_fnames: true,
},
mangle: false,
//mangle: {
// keep_classnames: true,
// keep_fnames: true,
// safari10: true,
//},
output: {
comments: false,
},
//keep_classnames: true,
//keep_fnames: true,
safari10: true,
},
extractComments: true,
}),
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, "src/index.html"),
minify: false
}),
new CleanWebpackPlugin(),
new CopyPlugin({
patterns: [
{
from: "static",
globOptions: {
ignore: ["**/publicroot"]
}
}
]
}),
new webpack.HotModuleReplacementPlugin(),
]
};