-
Notifications
You must be signed in to change notification settings - Fork 8
/
rollup.config.mts
46 lines (43 loc) · 1.22 KB
/
rollup.config.mts
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
import { builtinModules } from 'module'
import { defineConfig } from 'rollup'
import { minify, swc } from 'rollup-plugin-swc3'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import shim from '@rollup/plugin-esm-shim'
import dts from 'rollup-plugin-dts'
import commonjs from '@rollup/plugin-commonjs'
const external = [...builtinModules, 'vite']
const env = process.env.NODE_ENV
export default defineConfig([
{
input: {
cli: 'src/cli.ts',
index: 'src/server/index.ts'
},
external,
output: [
{ dir: 'dist', format: 'esm', exports: 'named', entryFileNames: '[name].mjs', chunkFileNames: '[name]-[hash].mjs' },
{ dir: 'dist', format: 'cjs', exports: 'named', entryFileNames: '[name].js' }
],
plugins: [
commonjs(),
nodeResolve(),
{
name: 'resolve-template',
resolveId(id) {
if (id === 'html.mjs') {
return { id: './html.mjs', external: true }
}
}
},
shim(),
swc(),
env !== 'development' && minify({ mangle: true, module: true, compress: true, sourceMap: true })
]
},
{
input: 'src/server/index.ts',
output: { file: 'dist/index.d.ts' },
plugins: [dts()],
external
}
])