-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
96 lines (91 loc) · 1.81 KB
/
rollup.config.mjs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Re: https://github.com/rollup/plugins/issues/1366
import { fileURLToPath } from 'node:url'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
import terser from '@rollup/plugin-terser'
import rollupReplace from '@rollup/plugin-replace'
const __filename = fileURLToPath(import.meta.url)
globalThis.__filename = __filename
function replace(opts) {
return rollupReplace({
...opts,
preventAssignment: true,
})
}
const external = ['shiki', 'skia-canvas']
const globals = {
shiki: 'shiki',
}
export default [
{
input: 'src/index.ts',
external,
output: [
{
file: 'dist/index.js',
format: 'cjs',
},
{
file: 'dist/index.mjs',
format: 'esm',
},
],
plugins: [
replace({
__BROWSER__: JSON.stringify(false),
}),
esbuild(),
nodeResolve(),
commonjs(),
],
},
{
input: 'src/index.ts',
external,
output: [
{
file: 'dist/index.iife.js',
format: 'iife',
extend: true,
name: 'shiki',
globals,
},
{
file: 'dist/index.iife.min.js',
format: 'iife',
extend: true,
name: 'shiki',
plugins: [terser()],
globals,
},
{
file: 'dist/index.browser.mjs',
format: 'esm',
globals,
},
],
treeshake: {
moduleSideEffects: false,
},
plugins: [
replace({
__BROWSER__: JSON.stringify(true),
}),
esbuild(),
nodeResolve(),
commonjs(),
],
},
{
input: 'src/index.ts',
output: [
{
file: 'dist/index.d.ts',
format: 'es',
},
],
plugins: [dts()],
},
]