-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.js
executable file
·59 lines (49 loc) · 1.36 KB
/
build.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
#!/usr/bin/env node
/* eslint-disable @typescript-eslint/no-require-imports */
// estrella build script
// ref: https://github.com/rsms/estrella
const pkg = require('./package.json')
const { build } = require('estrella')
const common = {
entry: 'src/index.ts',
bundle: true,
// esbuild options - https://esbuild.github.io/api/#build-api
sourcemap: true,
target: 'es2015', // ES versions: https://esbuild.github.io/content-types/#javascript
define: {
VERSION: JSON.stringify(pkg.version),
},
external: [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.peerDependencies || {})
],
}
const production = { ...common, minify: true }
const development = { ...common, debug: true, minify: false, target: 'es2018' }
const browser = { format: 'esm' }
const node = { format: 'cjs', platform: 'node' }
const esmProduction = {
...production, ...browser,
outfile: 'dist/ngrammy.esm.min.js',
}
const esmDevelopment = {
...development, ...browser,
outfile: 'dist/ngrammy.esm.js',
}
const nodeProduction = {
...production, ...node,
outfile: 'dist/ngrammy.min.cjs',
}
const nodeDevelopment = {
...development, ...node,
outfile: 'dist/ngrammy.cjs',
}
const builds = [
esmProduction,
esmDevelopment,
nodeProduction,
nodeDevelopment,
]
for (const config of builds) {
build(config)
}