-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
71 lines (63 loc) · 1.93 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
var webpack = require("webpack");
var path = require("path");
/* eslint-disable no-undef */
var environment = process.env["NODE_ENV"] || "development";
var soundPath = pathForRegexp("src/sounds");
var soundRegExp = new RegExp(soundPath + ".*\.(mp3|ogg|wav)$", "i");
var imagePath = pathForRegexp("src/images");
var imageRegExp = new RegExp(imagePath + ".*\.(jpe?g|png|gif|svg)$", "i");
var fontPath = pathForRegexp("src/fonts");
var fontRegExp = new RegExp(fontPath + ".*\.(eot|svg|ttf|woff2?)$", "i");
var htmlPath = pathForRegexp("src/");
var htmlRegExp = new RegExp(htmlPath + ".*\.html", "i");
function escapeForRegExp(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
}
function pathForRegexp(url) {
var normalized = path.resolve(__dirname, url);
return escapeForRegExp(normalized);
}
module.exports = {
entry: {
index: [ "./src/game" ]
},
devtool: "source-map",
output: {
path: __dirname + "/build/html",
filename: "[name].js"
},
module: {
preLoaders: [
// { test: /\.(js|json)$/, exclude: /node_modules/, loader: "eslint-loader" },
{
test: soundRegExp,
loader: "file?hash=sha512&digest=hex&name=[path][name].[ext]&context=src"
},
{
test: imageRegExp,
loaders: [
"file?hash=sha512&digest=hex&name=[path][name].[ext]&context=src"
//"image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false"
]
},
{
test: fontRegExp,
loader: "file?hash=sha512&digest=hex&name=[path][name].[ext]&context=src"
},
{
test: htmlRegExp,
loader: "file?hash=sha512&digest=hex&name=[path][name].[ext]&context=src"
}
],
loaders: [
{ test: /\.json$/, loader: "json" }
]
},
plugins: [
new webpack.DefinePlugin({
__PRODUCTION__: environment === "production",
__TEST__: environment === "test",
__DEVELOPMENT__: environment === "development"
})
]
};