-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts
67 lines (63 loc) · 1.93 KB
/
rollup.config.ts
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
63
64
65
66
67
import resolve from '@rollup/plugin-node-resolve'; // 在node_模块中查找并绑定第三方依赖项
import json from '@rollup/plugin-json'; // 将 .json 文件转换为 ES6 模块
import commonjs from '@rollup/plugin-commonjs'; // 将CommonJS模块转换为ES6
import alias from '@rollup/plugin-alias'; // 设置别名
import { babel } from '@rollup/plugin-babel'; // rollup babel插件
import esbuild from 'rollup-plugin-esbuild'; // 压缩
import serve from 'rollup-plugin-serve'; // 开发服务器
import livereload from 'rollup-plugin-livereload'; // 热更新服务
import path from 'path';
import {
author, name, version, license, main,
} from './package.json';
const banner = `
/**
* @license
* @author ${author}
* @name ${name}
* @version v${version}
* Released under the ${license} license.
*/`;
const isProd = process.env.NODE_ENV === 'production'; // 生产环境
export default {
input: 'src/demo/index.ts',
output: {
file: main,
format: 'esm',
banner,
},
watch: {
exclude: 'node_modules/**',
},
plugins: [
alias({
entries: {
'@': path.resolve(__dirname, 'src'),
},
}),
resolve(),
json(),
commonjs(),
babel({
babelHelpers: 'runtime',
extensions: ['.js', '.jsx', '.ts', '.tsx', '.scss'],
exclude: 'node_modules/**', // 只编译我们的源代码
}),
esbuild({
target: 'esnext',
minify: isProd,
}),
!isProd && serve({
host: 'localhost',
port: 8081,
open: true,
// openPage: 'examples/index.html',
historyApiFallback: 'examples/index.html',
contentBase: ['dist', 'examples'],
}),
!isProd && livereload({
watch: ['dist', 'examples'],
verbose: true, // Disable console output
}),
],
};