-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
93 lines (77 loc) · 1.96 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const Terser = require('terser-webpack-plugin')
const tsloader = require.resolve('ts-loader');
const merge = require("webpack-merge");
module.exports = (env = {}) => {
var isProd = !!env.prod;
const entry = {};
entry["GameTesterAVMPlayer"] = ["./src/GameTesterAVMPlayer.ts"];
const common = {
entry: entry,
output: {
pathinfo: false,
path: path.join(__dirname, "static", "avms", "scripts", "away"),
filename: '[name].js'
},
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: ['.webpack.js', '.web.js', '.js', '.ts', '.tsx']
},
module: {
rules: [
// all files with a `.ts` or `.tsx` extension will be handled by `tsloader`
{ test: /\.ts(x?)/, exclude: /node_modules/, loader: tsloader, options: { experimentalWatchApi: true} },
// all files with a `.js` or `.jsx` extension will be handled by `source-map-loader`
//{ test: /\.js(x?)/, loader: require.resolve('source-map-loader') }
]
},
performance: {
hints: false // wp4
},
stats: {
cached: true, // wp4
errorDetails: true, // wp4
colors: true // wp4
},
devServer: {
progress: true, // wp4
},
}
const dev = {
mode: "development",// wp4
devtool: 'source-map',
//devtool: 'cheap-module-eval-source-map',//use this option for recompiling libs
devServer: {
contentBase: path.join(process.cwd(), "src"),
inline: true,
publicPath: "/",
open: false,
progress: true,
},
optimization: {
//minimize: false // wp4
}
}
const prod = {
mode: "production",// wp4
bail: true
};
if(Terser) {
prod.optimization = {
minimize: true,
minimizer: [
new Terser({
extractComments: {
condition: /^\**!|@preserve|@license|@cc_on/i,
filename: 'LICENSES.txt'
},
}),
],
}
} else {
console.warn("TERSER IS REQUIRE FOR REMOVING COMMENTS!");
}
return merge(common, isProd ? prod : dev);
}