-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.ts
More file actions
53 lines (45 loc) · 1.11 KB
/
rollup.config.ts
File metadata and controls
53 lines (45 loc) · 1.11 KB
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 esbuild from 'rollup-plugin-esbuild'// 将 ts 转换成 js
import resolve from '@rollup/plugin-node-resolve' // 让rollup支持nodejs的模块解析机制
import commonjs from '@rollup/plugin-commonjs' // 将CommonJs模块转换为es6
import json from '@rollup/plugin-json' // 将json文件转换为es6
import { defineConfig } from 'rollup'
import fse from 'fs-extra'
import pkg from './package.json'
import { createEntries } from './utils/index.mjs'
const files = fse.readdirSync('src')
const entries = {}
files.forEach((file) => {
createEntries(file, __dirname, 'src', entries)
})
const plugins = [
resolve({
preferBuiltins: true,
}),
json(),
commonjs(),
esbuild({
target: 'node14',
}),
]
function onwarn(message) {
if (message.code === 'EMPTY_BUNDLE')
return
console.error(message)
}
const external = [
...Object.keys(pkg.dependencies || {}),
]
export default defineConfig([
{
input: entries,
output: {
dir: 'dist',
format: 'esm',
entryFileNames: '[name].mjs',
chunkFileNames: 'chunk-[name].mjs',
},
external,
plugins,
onwarn,
},
])