forked from codergautam/spicywar.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpackprod.config.js
42 lines (40 loc) · 1.03 KB
/
webpackprod.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
//const webpack = require("webpack");
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
function uuidv4() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == "x" ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
const config = {
entry: "./src/index.ts",
plugins: [
new CopyPlugin({
patterns: [
{ from: "src/index.html", to: "", transform(content) {
return content
.toString()
.replace("RANDOM_UUID", uuidv4());
}},
],
}),
],
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: [".ts", ".tsx", ".js"]
},
module: {
rules: [
// all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
{ test: /\.tsx?$/, loader: "ts-loader" }
]
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "main.js",
},
devtool: "source-map",
mode: "production"
};
module.exports = config;