This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.aegir.js
52 lines (46 loc) · 1.54 KB
/
.aegir.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
import path, { dirname } from "path";
import { fileURLToPath } from "url";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const __dirname = dirname(fileURLToPath(import.meta.url));
// https://github.com/node-webrtc/node-webrtc/issues/636#issuecomment-774171409
process.on("beforeExit", (code) => process.exit(code));
// https://github.com/ipfs/aegir/blob/master/md/migration-to-v31.md
const esbuild = {
// this will inject all the named exports from 'node-globals.js' as globals
inject: [path.join(__dirname, "./scripts/node-globals.js")],
external: ["fs", "path", "os", "chokidar", "url", "zlib", "rimraf"],
plugins: [
{
name: "node built ins", // this will make the bundler resolve node builtins to the respective browser polyfill
setup(build) {
build.onResolve({ filter: /^stream$/ }, () => {
return { path: require.resolve("stream-browserify") };
});
build.onResolve({ filter: /^os$/ }, () => {
return { path: require.resolve("os-browserify") };
});
build.onResolve({ filter: /^crypto$/ }, () => {
return { path: require.resolve("crypto-browserify") };
});
build.onResolve({ filter: /^fs/ }, () => {
return { path: require.resolve("browserify-fs") };
});
},
},
],
};
/** @type {import('aegir').PartialOptions} */
const options = {
test: {
browser: {
config: {
buildConfig: esbuild,
},
},
},
build: {
config: esbuild,
},
};
export default options;