Linux command
rollup 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Bundle JavaScript
rollup [main.js] --file [bundle.js]
Use configuration file
rollup -c
Output format
rollup [main.js] -o [bundle.js] -f [es]
Watch for changes
rollup -c --watch
Generate sourcemap
rollup [main.js] -o [bundle.js] -m
Bundle with a specific plugin
rollup [main.js] -o [bundle.js] -p [node-resolve]
说明
rollup is a JavaScript module bundler focused on ES modules. It compiles small pieces of code into larger bundles, with excellent tree-shaking to eliminate unused code. The tool produces efficient bundles for libraries and applications, supporting multiple output formats.
参数
- -c _file_, --config _file_
- Configuration file.
- -o _file_, --file _file_
- Output file.
- -f _fmt_, --format _fmt_
- Output format (es, cjs, umd, iife, amd, system).
- -n _name_, --name _name_
- UMD/IIFE global name.
- -m, --sourcemap
- Generate sourcemap.
- -w, --watch
- Watch mode.
- -p _plugin_, --plugin _plugin_
- Use plugin.
- -d _dir_, --dir _dir_
- Output directory (for code splitting).
- -e _modules_, --external _modules_
- Comma-separated list of external module IDs.
- -g _pairs_, --globals _pairs_
- Comma-separated global:module pairs for UMD/IIFE.
- --no-treeshake
- Disable tree shaking.
FAQ
What is the rollup command used for?
rollup is a JavaScript module bundler focused on ES modules. It compiles small pieces of code into larger bundles, with excellent tree-shaking to eliminate unused code. The tool produces efficient bundles for libraries and applications, supporting multiple output formats.
How do I run a basic rollup example?
Run `rollup [main.js] --file [bundle.js]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -c _file_, --config _file_ do in rollup?
Configuration file.