-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
53 lines (47 loc) · 1.18 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
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'
import copy from 'rollup-plugin-copy'
import { terser } from 'rollup-plugin-terser'
const packageJSON = JSON.parse(readFileSync(resolve('./package.json'), 'utf-8'))
const OUTPUT_DIR = 'lib'
const COPY_FILES = [
'config/markdownlint.json',
'package.json',
'README.md',
]
const createConfig = (configFile, format) => ({
external: Object.keys(packageJSON.dependencies),
input: configFile,
output: {
dir: OUTPUT_DIR,
format,
},
plugins: [
nodeResolve(),
typescript(),
],
})
export default [{
external: Object.keys(packageJSON.dependencies),
input: 'src/index.ts',
output: {
file: `${OUTPUT_DIR}/index.min.js`,
format: 'es',
},
plugins: [
nodeResolve({
preferBuiltins: true,
}),
typescript(),
terser(),
copy({
targets: COPY_FILES.map(file => ({ src: file, dest: OUTPUT_DIR })),
}),
],
},
createConfig('config/all-legacy.ts', 'cjs'),
createConfig('config/all.ts', 'es'),
createConfig('config/stylelint.config.js', 'cjs'),
]