-
Notifications
You must be signed in to change notification settings - Fork 5
/
rollup.config.js
58 lines (50 loc) · 1.46 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
54
55
56
57
58
import babel from "rollup-plugin-babel"
import resove from 'rollup-plugin-node-resolve'
import filesize from 'rollup-plugin-filesize'
// 多入口文件
import multiInput from 'rollup-plugin-multi-input'
// 压缩
import {
terser
} from "rollup-plugin-terser"
// 输出文件夹清除
import clear from "rollup-plugin-clear"
const path = require('path')
const resolve = function (filePath) {
return path.join(__dirname, filePath)
}
const extensions = [".ts", ".js"]
/** 文件遍历 */
const glob = require('glob')
const files = glob.sync('./src/**/*.ts');
let filesArr = []
files.map(file => {
const name = path.basename(file, path.extname(file))
// console.log(file.slice(2, file.length - 3), name)
filesArr.push({
input: file,
output: [{
// file: resolve(`lib/${name}.esm.min.js`),
format: 'esm',
dir: 'lib'
}, ],
plugins: [
clear({
targets: ["lib", 'dist', 'types']
}),
resove({
extensions: ['.ts', '.js', '.json'],
}),
multiInput(), // 根据目录生成输出文件
babel({
exclude: 'node_modules/**',
extensions
}),
terser(),
filesize()
],
external: ['dayjs', 'js-cookie', 'lodash', 'dom-to-image']
})
})
/** -------------------------------------------------------- */
export default filesArr