-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.config.js
42 lines (38 loc) · 1.14 KB
/
esbuild.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
import process from 'node:process'
import esbuild from 'esbuild'
import { Effect, Match, pipe } from 'effect'
const MODE = process.env.MODE ?? 'lib'
const entry = Match.value(MODE).pipe(
Match.when('lib-debug', () => './lib/leaky-paywall-debug.js'),
Match.when('lib-preview', () => './lib/leaky-paywall-preview.js'),
Match.orElse(() => './lib/leaky-paywall.js'),
)
const output = Match.value(MODE).pipe(
Match.when('lib-debug', () => './lib/leaky-paywall-debug.min.js'),
Match.when('lib-preview', () => './lib/leaky-paywall-preview.min.js'),
Match.orElse(() => './lib/leaky-paywall.min.js'),
)
await pipe(
Effect.log(`Minify ${entry} -> ${output}`),
Effect.flatMap(() =>
Effect.promise(() =>
esbuild.build({
logLevel: 'info',
entryPoints: [entry],
bundle: true,
minify: true,
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
__VUE_OPTIONS_API__: 'false',
__VUE_PROD_DEVTOOLS__: 'false',
},
outfile: output,
}),
),
),
Effect.catchAllDefect((error) => {
console.error(error)
process.exit(1)
}),
Effect.runPromise,
)