-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.config.js
More file actions
74 lines (65 loc) · 2.42 KB
/
extension.config.js
File metadata and controls
74 lines (65 loc) · 2.42 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
69
70
71
72
73
74
module.exports = {
browser: {
chrome: {
chromeBinary: "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe",
},
},
config: (config) => {
if (config.mode === "production") {
// Keep source maps in dev, but omit them from production builds.
config.devtool = false;
// Production bundles must not ship dev-only hot reload runtime into
// the extension service worker or UI entrypoints.
config.plugins = (config.plugins || []).filter((plugin) => {
const name = plugin?.constructor?.name || "";
return !name.includes("ReactRefresh") && !name.includes("HotModuleReplacement");
});
if (config.builtins?.react) {
config.builtins.react = {
...config.builtins.react,
refresh: false,
};
}
}
// Node.js CLI scripts in tools-cli/ may still appear as implicit
// dependencies during production builds -- stub out node builtins.
config.resolve = config.resolve || {};
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
path: false,
};
// The browser bundle includes the vendored TypeScript runtime for sandbox
// parsing/transpilation. Keep Node globals mocked, but suppress the known
// webpack-compatible warnings emitted from typescript.js itself.
config.node = {
...config.node,
__dirname: "mock",
__filename: "mock",
};
config.ignoreWarnings = [
...(config.ignoreWarnings || []),
(warning) => {
const resource = warning?.module?.resource || "";
const message = warning?.message || "";
const isTypeScriptRuntime = resource.includes("node_modules/typescript/lib/typescript.js")
|| message.includes("node_modules/typescript/lib/typescript.js");
if (!isTypeScriptRuntime) return false;
return message.includes("__filename")
|| message.includes("__dirname")
|| message.includes("the request of a dependency is an expression");
},
];
// Inject build timestamp and package version as global constants.
const { DefinePlugin } = require("@rspack/core");
const pkg = require("./package.json");
config.plugins = config.plugins || [];
config.plugins.push(
new DefinePlugin({
__BUILD_TIMESTAMP__: JSON.stringify(new Date().toISOString()),
__APP_VERSION__: JSON.stringify(pkg.version),
}),
);
return config;
},
};