forked from huangkairan/api-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
53 lines (51 loc) · 1.23 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
/* eslint-disable @typescript-eslint/no-var-requires */
import json from '@rollup/plugin-json'
import { terser } from 'rollup-plugin-terser'
import { cleandir } from 'rollup-plugin-cleandir'
import typescript from 'rollup-plugin-typescript2'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import { preserveShebangs } from 'rollup-plugin-preserve-shebangs'
import alias from '@rollup/plugin-alias'
import copy from 'rollup-plugin-copy'
const extensions = ['.js', '.ts']
export default {
input: ['./src/index.ts', './src/core.ts'],
output: {
dir: './lib/core',
format: 'cjs'
},
plugins: [
cleandir('./lib'),
// 处理#!/usr/bin/env node
preserveShebangs(),
alias({
entries: [
{ find: '@', replacement: '../src' }
]
}),
// 解析typescript
typescript({
tsconfigOverride: {
compilerOptions: {
module: 'ESNEXT'
}
}
}),
// 解析node_modules
nodeResolve({
extensions,
modulesOnly: true,
preferredBuiltins: false
}),
// 将JSON转换为ES6版本
json(),
// 代码压缩
terser(),
// 拷贝静态文件
copy({
targets: [
{ src: 'src/templates/', dest: 'lib/' }
]
})
]
}