forked from bs-community/blessing-skin-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
60 lines (56 loc) · 1.44 KB
/
rollup.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// @ts-check
import glob from 'fast-glob'
import typescript from '@rollup/plugin-typescript'
import replace from '@rollup/plugin-replace'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { terser } from 'rollup-plugin-terser'
import svelte from 'rollup-plugin-svelte'
import sveltePreprocess from 'svelte-preprocess'
const isDev = process.env.NODE_ENV === 'development'
/**
* @param {string} name
* @param {string} path
*
* @returns {import('rollup').RollupOptions}
*/
function makeConfig(name, path) {
return {
input: { [name]: path },
output: {
dir: './plugins',
format: 'iife',
globals: {
'blessing-skin': 'blessing',
react: 'React',
'react-dom': 'ReactDOM',
},
indent: ' ',
sourcemap: isDev,
},
external: ['react', 'react-dom', 'blessing-skin'],
plugins: [
replace({
'process.env.NODE_ENV': isDev ? '"development"' : '"production"',
}),
typescript(),
svelte({
preprocess: sveltePreprocess(),
}),
resolve({ browser: true }),
commonjs(),
!isDev && terser(),
],
}
}
export default glob([
'plugins/*/assets/**/*.ts',
'plugins/*/assets/**/*.tsx',
'!plugins/*/assets/**/*.test.ts',
'!**/*.d.ts',
]).then((files) =>
files.map((file) => {
const name = file.replace('plugins/', '').replace(/\.tsx?$/g, '')
return makeConfig(name, file)
}),
)