-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
90 lines (78 loc) · 1.99 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
const webpack = require("webpack");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
module.exports = {
module: {
rules: [
{
include: [path.resolve(__dirname, "src/client/images")],
loader: "url-loader"
},
{
include: [path.resolve(__dirname, "src/client")],
loader: "babel-loader",
options: {
plugins: ["syntax-dynamic-import", "transform-object-rest-spread"],
presets: [
[
"env",
{
modules: false
}
]
]
},
test: /\.js$/
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
}
]
},
devtool: "source-map",
entry: {
editor: "./src/client/editor",
player: "./src/client/player"
},
output: {
filename: "js/[name].js",
path: path.resolve(__dirname, "public")
},
mode: process.env.NODE_ENV || "development",
plugins: [
...(process.env.NODE_ENV === "production"
? [
// p5.min.js is not just a minification of p5.js, it also omits the
// embedded documentation, so it's a win to use p5.min.js even though
// we minimize everything in the end
new webpack.NormalModuleReplacementPlugin(/.*\/p5.js$/, "p5.min.js"),
new CompressionPlugin()
]
: []),
new HtmlWebpackPlugin({
filename: "index.html",
hash: true,
chunks: ["player"],
template: path.resolve(__dirname, "src/client/template.html")
}),
new HtmlWebpackPlugin({
filename: "editor.html",
hash: true,
chunks: ["editor"],
template: path.resolve(__dirname, "src/client/template.html")
})
],
devServer: {
compress: true,
host: "0.0.0.0",
overlay: true,
proxy: {
"/socket.io": {
target: "http://localhost:3000",
ws: true
}
}
}
};