generated from melonjs/es6-boilerplate
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
102 lines (98 loc) · 2.54 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
94
95
96
97
98
99
100
101
102
const path = require('path');
const fs = require("fs");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
require("@babel/register");
module.exports = {
entry: "./src/index.js",
output: {
path: __dirname + "/docs",
filename: "bundle.js",
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
generatorOpts: { compact: false },
presets: ["@babel/preset-env"],
},
},
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html",
hash: true,
}),
new CopyWebpackPlugin({
patterns: [
{
from: "./src/data",
to: "./data",
filter: async (resourcePath) => {
const data = await fs.promises.readFile(resourcePath);
// add your custom extension here if not listed
var texture = /\.(jpe?g|gif|png|svg|heic|avif|webp|pkm|pvr)$/;
var fnt = /\.(woff|woff2|ttf|fnt)$/;
var map = /\.(tmx|tmj|tsx|tsj)$/;
var audio = /\.(wav|mp3|mpeg|opus|ogg|oga|wav|aac|caf|m4a|m4b|mp4|weba|webm|dolby|flac)$/;
var misc = /\.(xml|bin|glsl|ym|json|js)$/;
// only copy production files
var ret = texture.test(resourcePath) || fnt.test(resourcePath) || map.test(resourcePath) || audio.test(resourcePath) || misc.test(resourcePath);
if (ret === false) {
console.log("ignoring data: " + resourcePath);
}
return ret;
},
},
],
}),
new FaviconsWebpackPlugin({
logo: "./src/favicon/logo.png", // svg works too!
mode: "auto", // optional can be 'webapp', 'light' or 'auto' - 'auto' by default
devMode: "webapp", // optional can be 'webapp' or 'light' - 'light' by default
favicons: {
appName: "melonJS ES6 Boilerplate",
appDescription: "My melonJS ES6 Boilerplate Game",
developerName: "melonJS",
developerURL: "http://www.melonjs.org", // prevent retrieving from the nearest package.json
icons: {
coast: false,
yandex: false,
appleStartup: false,
},
},
}),
],
resolve: {
modules: [path.resolve("./src"), path.resolve("./node_modules")],
fallback: {
"path" : false,
"fs": false
}
},
performance: {
hints: false,
maxEntrypointSize: 524288,
maxAssetSize: 524288
},
devServer: {
static: {
directory: path.join(__dirname, "docs"),
},
compress: true,
hot: true,
port: 9000,
open: true,
}
};