-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcraco.config.js
75 lines (63 loc) · 2.28 KB
/
craco.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
const { when, whenDev, addBeforeLoader, loaderByName } = require("@craco/craco");
const ThreadsPlugin = require("threads-plugin");
const JsonMinimizerPlugin = require("json-minimizer-webpack-plugin");
const express = require("express");
module.exports = {
webpack: {
configure: (webpackConfig) => {
const glslLoader = {
test: /\.(glsl|vs|fs)$/,
loader: "ts-shader-loader",
};
// Kind of a hack to get the glsl loader to work
// https://github.com/dilanx/craco/issues/486
for (const rule of webpackConfig.module.rules) {
if (rule.oneOf) {
rule.oneOf.unshift(glslLoader);
break;
}
}
webpackConfig.module.rules.push({
resourceQuery: /url/,
type: "asset/resource",
});
webpackConfig.module.rules.push({
resourceQuery: /source/,
type: "asset/source",
});
// addBeforeLoader(webpackConfig, loaderByName('file-loader'), glslLoader);
webpackConfig.resolve.fallback = {
fs: false,
};
webpackConfig.resolve.extensions = [".web.js", ...webpackConfig.resolve.extensions];
webpackConfig.optimization.minimizer.push(new JsonMinimizerPlugin());
return webpackConfig;
},
plugins: [new ThreadsPlugin()],
},
devServer: {
headers: {
"Cross-Origin-Opener-Policy": "same-origin",
"Cross-Origin-Embedder-Policy": "require-corp",
},
client: {
overlay: {
errors: true,
warnings: false,
runtimeErrors: (error) => {
if (error instanceof DOMException && error.name === "AbortError") {
return false;
}
return true;
},
},
},
setupMiddlewares: (middlewares, devServer) => {
if (!devServer) {
throw new Error("webpack-dev-server is not defined");
}
devServer.app.use("/caches", express.static("caches"));
return middlewares;
},
},
};