-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.js
40 lines (36 loc) · 889 Bytes
/
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
const { build } = require('esbuild')
const { sassPlugin } = require('esbuild-sass-plugin')
const { nodeExternalsPlugin } = require('esbuild-node-externals')
const { globSync } = require('glob')
const entryFile = 'src/index.ts'
const shared = {
bundle: true,
entryPoints: [entryFile],
logLevel: 'info',
minify: true,
sourcemap: true,
plugins: [sassPlugin(), nodeExternalsPlugin()],
loader: {
'.svg': 'file',
},
}
build({
...shared,
format: 'esm',
outfile: './dist/index.esm.js',
target: ['esnext', 'node12.22.0'],
})
// Build separate css files to be able to only include one component
build({
...shared,
format: 'esm',
outdir: './dist/css/',
target: ['esnext', 'node12.22.0'],
entryPoints: globSync('./src/components/**/index.ts'),
})
build({
...shared,
format: 'cjs',
outfile: './dist/index.cjs.js',
target: ['esnext', 'node12.22.0'],
})