-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
85 lines (83 loc) · 2.18 KB
/
webpack.config.ts
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
import * as path from "path"
import CopyPlugin from "copy-webpack-plugin"
import HtmlPlugin from "html-webpack-plugin"
import { Configuration, EnvironmentPlugin } from "webpack"
import "webpack-dev-server"
const config = (env: unknown, argv: any): Configuration => ({
devtool: "source-map",
module: {
rules: [
{
resourceQuery: /raw/,
type: "asset/source",
},
{
test: /\.tsx?$/,
include: [path.resolve(__dirname, "src")],
use: {
loader: "@sucrase/webpack-loader",
options: {
transforms: ["typescript", "jsx"],
production: argv.mode === "production",
},
},
},
{
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre",
},
{
test: /\.(glslx?|vert|frag)$/,
use: {
loader: "val-loader",
options: {
executableFile: path.resolve(__dirname, "glsl-loader.mjs"),
},
},
},
{
resourceQuery: { not: /raw/ },
test: /\.(png|svg|jpg|jpeg|gif|ttf)$/i,
type: "asset/resource",
},
],
},
plugins: [
new HtmlPlugin({ template: "./index.html" }),
new CopyPlugin({
patterns: [{ from: "static", to: "." }],
}),
new EnvironmentPlugin({
GIT_HASH: process.env.GITHUB_SHA ?? "??????",
BUILD_TIME: new Date().toISOString(),
}),
],
output: {
publicPath: "/workshop/",
clean: true,
devtoolModuleFilenameTemplate: "/dev/[namespace]/[resource-path]?[loaders]",
},
resolve: {
extensions: [".ts", ".js", ".tsx", ".jsx"],
alias: {
ts3dutils: __dirname + "/node_modules/ts3dutils/lib/index.es.min",
tsgl: __dirname + "/node_modules/tsgl/lib/index.es.min",
pdfkit: __dirname + "/node_modules/pdfkit/js/pdfkit.standalone.js",
// standalone version of blob-stream, to avoid
// having to polyfill buffer etc
"blob-stream": __dirname + "/node_modules/blob-stream/.js",
},
},
node: {
global: true,
},
optimization: {
usedExports: true,
},
devServer: {
historyApiFallback: { index: "/workshop/404.html" },
hot: true,
},
})
export default config