-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeno-bundle.ts
47 lines (44 loc) · 1.24 KB
/
deno-bundle.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
import { build, context, type BuildOptions } from 'esbuild';
import esbuildSvelte from 'esbuild-svelte';
import { sveltePreprocess } from 'svelte-preprocess';
import manifest from './manifest.json' with { type: 'json' };
const isProd = process.env.NODE_ENV === 'production';
console.log('🚧', process.env.NODE_ENV);
const buildOptions: BuildOptions = {
plugins: [
esbuildSvelte({
preprocess: sveltePreprocess(),
compilerOptions: { dev: !isProd },
}),
],
entryPoints: [
'./src/api-monitor-devtools.ts',
'./src/api-monitor-cs-main.ts',
'./src/api-monitor-cs-isolated.ts',
'./src/api-monitor-devtools-panel.ts',
],
outdir: './public/build/',
define: {
__development__: `${!isProd}`,
__app_name__: `"browser-api-monitor@${manifest.version}"`,
__app_version__: `"${manifest.version}"`,
__home_page__: `"${manifest.homepage_url}"`,
},
bundle: true,
platform: 'browser',
format: 'iife',
target: 'esnext',
conditions: [`${process.env.NODE_ENV}`],
minify: isProd,
sourcemap: false,
treeShaking: true,
logLevel: 'debug',
};
if (isProd) {
build(buildOptions).catch((error) => {
console.error(error);
});
} else {
const ctx = await context(buildOptions);
await ctx.watch();
}