-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrollup.config.ts
51 lines (48 loc) · 1.48 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
import commonjs from '@rollup/plugin-commonjs';
import sourcemaps from 'rollup-plugin-sourcemaps2';
import nodeResolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import dts from 'rollup-plugin-dts';
import process from 'node:process';
import type { RollupOptions } from 'rollup';
const { BUILD } = process.env;
const browser = BUILD === 'browser';
const config: RollupOptions[] = [
{
input: 'src/index.ts',
output: {
file: browser ? 'release/versatiles-style/versatiles-style.js' : 'dist/index.js',
format: browser ? 'umd' : 'es',
sourcemap: true,
indent: !browser,
name: 'VersaTilesStyle'
},
plugins: [
browser && terser({ compress: { pure_getters: true, passes: 3 }, sourceMap: true }),
nodeResolve({ browser }),
typescript({
tsconfig: './tsconfig.json',
include: ['src/**/*.ts'],
exclude: ['**/*.test.ts'],
sourceMap: true,
declaration: true,
declarationDir: browser ? 'release/versatiles-style/declaration' : 'dist/declaration',
}),
commonjs(),
sourcemaps(),
],
onLog(level, log, handler) {
if (log.code === 'CIRCULAR_DEPENDENCY') return;
handler(level, log);
}
}, {
input: browser ? 'release/versatiles-style/declaration/index.d.ts' : 'dist/declaration/index.d.ts',
output: {
file: browser ? 'release/versatiles-style/versatiles-style.d.ts' : 'dist/index.d.ts',
format: 'es'
},
plugins: [dts()],
}
]
export default config;