forked from bs-community/blessing-skin-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
56 lines (53 loc) · 1.33 KB
/
rollup.config.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
48
49
50
51
52
53
54
55
56
import glob from 'fast-glob'
import { defineConfig } from 'rollup'
import replace from '@rollup/plugin-replace'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { swc } from 'rollup-plugin-swc3'
import svelte from 'rollup-plugin-svelte'
import sveltePreprocess from 'svelte-preprocess'
const isDev = process.env.NODE_ENV === 'development'
function makeConfig(name: string, path: string) {
return defineConfig({
input: { [name]: path },
output: {
dir: './plugins',
format: 'esm',
},
plugins: [
replace({
values: {
'process.env.NODE_ENV': isDev ? '"development"' : '"production"',
},
preventAssignment: true,
}),
swc({
jsc: {
target: 'es2020',
minify: isDev
? undefined
: {
compress: {},
mangle: {},
},
},
minify: !isDev,
}),
svelte({
preprocess: sveltePreprocess(),
emitCss: false,
}),
resolve({ browser: true }),
commonjs(),
],
})
}
export default glob([
'plugins/*/assets/**/*.ts',
'!plugins/*/assets/**/*.test.ts',
'!**/*.d.ts',
]).then((files) =>
files.map((file) =>
makeConfig(file.replace('plugins/', '').replace(/\.ts$/g, ''), file),
),
)