入门 - Rollup

入门

配置文件

  • rollup -c
1
2
3
4
5
6
7
8
// rollup.config.js
export default {
input: "src/main.js",
output: {
file: "bundle.js",
format: "cjs",
},
};

(不相关的)批次构建

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// rollup.config.js (building more than one bundle)

export default [
{
input: "main-a.js",
output: {
file: "dist/bundle-a.js",
format: "cjs",
},
},
{
input: "main-b.js",
output: [
{
file: "dist/bundle-b1.js",
format: "cjs",
},
{
file: "dist/bundle-b2.js",
format: "es",
},
],
},
];

配置智能提示

1
2
3
4
// rollup.config.js
/**
* @type {import('rollup').RollupOptions}
*/

npm包加载

1
2
3
# 这将首先尝试加载包 "rollup-config-my-special-config"
# 如果失败,则尝试加载 "my-special-config"
rollup --config node:my-special-config

插件

代码分割

SystemJS


入门 - Rollup
https://wanmeishijie.xyz/notes/rollup/入门/
作者
发布于
2024年3月2日
许可协议