-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
59 lines (53 loc) · 1.54 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
import typescript from 'rollup-plugin-typescript2'
import {
terser
} from 'rollup-plugin-terser'
import autoprefixer from "autoprefixer"
import postcss from 'rollup-plugin-postcss'
import {
nodeResolve
} from '@rollup/plugin-node-resolve' //将外部引入的js打包进来
import babel from '@rollup/plugin-babel'
import del from 'rollup-plugin-delete' //
import commonjs from '@rollup/plugin-commonjs' //将CommonJS模块转换为ES6, 方便rollup直接调用
import livereload from 'rollup-plugin-livereload'
const bundleSize = require('rollup-plugin-bundle-size');
const isProduction = process.env.NODE_ENV === 'production'
export default {
input: './src/web-message.ts',
output: [{
format: 'umd',
file: 'dist/web-message.umd.js',
name: 'WebMessage',
},
{
format: 'es',
file: 'dist/web-message.esm.js',
},
],
plugins: [
isProduction && terser(),
isProduction && del({
targets: ['dist']
}),
nodeResolve(),
commonjs({
include: 'node_modules/**',
}),
postcss({
plugins: [autoprefixer()],
}),
babel({
exclude: 'node_modules/**',
babelHelpers: "runtime"
}),
// 热更新
!isProduction && livereload("./src"),
typescript({
exclude: 'node_modules/**',
useTsconfigDeclarationDir: true,
extensions: ['.js', '.ts', '.tsx'],
}),
bundleSize()
],
}