-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
77 lines (75 loc) · 1.98 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
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
const CopyPlugin = require("copy-webpack-plugin");
function normalizeName(name) {
return name.replace(/node_modules/g, "").replace(/[\-_.|]+/g, " ")
.replace(/\b(vendors|nodemodules|js|modules|es)\b/g, "")
.trim().replace(/ +/g, "-");
}
module.exports = {
mode: "development",
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "docs"),
filename: "[name].bundle.js",
},
// Need this because for some reason the default bundle name for firebase (node_modules_firebase_app_dist_index_esm_js.bundle)
// causes a bug in gh-pages. The file can't be loaded for some reason. This code below changes the
// Default bundle names so that it works.
optimization: {
splitChunks: {
chunks: 'all',
name: (module, chunks, cacheGroupKey) => {
const allChunksNames = chunks.map((chunk) => chunk.name).join('~');
const prefix = cacheGroupKey === 'defaultVendors' ? 'vendors' : cacheGroupKey;
return `${prefix}~${allChunksNames}`;
},
},
},
plugins: [
new HtmlWebpackPlugin({
template: "public/index.html",
}),
],
module: {
rules: [
{
test: /\.js$/i,
include: path.resolve(__dirname, "src"),
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
},
},
},
{
test: /\.s[ac]ss$/i,
include: [path.resolve(__dirname, "src")],
use: ["style-loader", "css-loader", "sass-loader"],
},
{
test: /\.glsl/,
include: [path.resolve(__dirname, "src")],
type: "asset/source",
},
{
test: /\.css$/i,
include: [path.resolve(__dirname, "src")],
use: ["style-loader", "css-loader", "postcss-loader"],
},
],
},
devServer: {
host: '0.0.0.0',
port: 8030,
allowedHosts: ['all'],
static: {
directory: path.join(__dirname, "public"),
},
historyApiFallback: {
index: "public/index.html",
},
},
};