-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
62 lines (60 loc) · 1.3 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
59
60
61
62
import ts from '@rollup/plugin-typescript'
import { terser } from 'rollup-plugin-terser'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import postcss from 'rollup-plugin-postcss'
const pkg = require('./package.json')
const banner = `
/*!
* ${pkg.name}
* v${pkg.version}
* by ${pkg.author}
*/
`
export default {
input: 'src/index.ts',
output: [
{
dir: "./",
entryFileNames: 'dist/[name].umd.js',
format: 'umd',
name: pkg.name,
banner
},
{
dir: "./",
entryFileNames: 'dist/[name].esm.js',
format: 'es',
banner
}
],
plugins: [
nodeResolve(),
commonjs(),
ts({
sourceMap: false,
// 生成 .d.ts 文件。参考:https://github.com/rollup/plugins/issues/61#issuecomment-597090769
declaration: true,
declarationDir: 'types/',
rootDir: 'src/'
}),
terser({
output: {
comments: (node, comment) => {
const text = comment.value
const type = comment.type
if (type == 'comment2') {
// multiline comment
return /^!/.test(text)
}
}
}
}),
postcss({
// css module
modules: true,
extract: 'dist/index.css',
minimize: true
})
]
}