-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
68 lines (63 loc) · 1.58 KB
/
webpack.config.js
File metadata and controls
68 lines (63 loc) · 1.58 KB
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
import path from "path";
import HTMLWebpackPlugin from "html-webpack-plugin";
import { CleanWebpackPlugin } from "clean-webpack-plugin";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const repoName = process.env.GITHUB_REPOSITORY ? process.env.GITHUB_REPOSITORY.split('/')[1] : '';
const isGhPages = process.env.GITHUB_PAGES === "true";
export default {
context: path.resolve(__dirname, "src"),
mode: "development",
entry: {
main: "./index.js",
},
output: {
filename: "[name].[contenthash].js",
path: path.resolve(__dirname, "build"),
publicPath: isGhPages ? `/${repoName}/` : '/',
},
plugins: [
new HTMLWebpackPlugin({
template: "./index.html",
}),
new CleanWebpackPlugin(),
],
devServer: {
port: 3000,
host: "0.0.0.0",
allowedHosts: "all",
hot: true,
open: false,
historyApiFallback: true,
},
resolve: {
extensions: [".js", ".ts", ".tsx"],
extensionAlias: {
".js": [".ts", ".js"],
".mjs": [".mts", ".mjs"],
},
},
module: {
rules: [
{
test: /\.(glsl|vs|fs|vert|frag)$/,
exclude: /node_modules/,
use: ["raw-loader", "glslify-loader"],
},
{
test: /\.(jpe?g|gif|png|svg|woff|ttf|wav|mp3)$/,
exclude: /node_modules/,
type: "asset/resource",
generator: {
filename: "public/[name][hash][ext][query]",
},
},
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
],
},
};