forked from ipfs/js-ipfs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.aegir.js
60 lines (55 loc) · 1.39 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
53
54
55
56
57
58
59
60
import path from 'path'
import esbuild from 'esbuild'
import EchoServer from 'aegir/echo-server'
import { fileURLToPath } from 'url'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
/** @type {import('aegir').Options["build"]["config"]} */
const buildConfig = {
inject: [path.join(__dirname, '../../scripts/node-globals.js')]
}
/** @type {import('aegir').PartialOptions} */
export default {
build: {
bundlesizeMax: '32KB',
config: buildConfig
},
test: {
browser: {
config: {
assets: '..',
buildConfig
}
},
async before () {
await buildWorker()
const echoServer = new EchoServer()
await echoServer.start()
return {
echoServer,
env: {
IPFS_WORKER_URL: '/ipfs-message-port-client/dist/worker.bundle.js',
ECHO_SERVER: `http://${echoServer.host}:${echoServer.port}`
}
}
},
async after (options, before) {
await before.echoServer.stop()
}
}
}
const buildWorker = async () => {
await esbuild.build(
{
entryPoints: [path.join(__dirname, 'test/util/worker.js')],
bundle: true,
mainFields: ['browser', 'module', 'main'],
sourcemap: 'inline',
outfile: path.join(__dirname, 'dist/worker.bundle.js'),
define: {
global: 'globalThis',
'process.env.NODE_ENV': '"production"'
},
...buildConfig
}
)
}