Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions build-plugins/load-cli-help.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { readFile } from 'node:fs/promises';
import type { Plugin } from 'rollup';

export default function loadCliHelp(): Plugin {
return {
async load(id) {
if (id.endsWith('help.md')) {
const [rawHelpFile, packageFile] = await Promise.all([
readFile(id, 'utf8'),
readFile(new URL('../package.json', import.meta.url), 'utf8')
]);
const finalHelpFile = rawHelpFile
.replaceAll(/^\/\/\s*#(end)?region[^\n]*\n/gm, '')
.replace('__VERSION__', JSON.parse(packageFile).version);
return `export default ${JSON.stringify(finalHelpFile)};`;
}
return null;
},
name: 'load-cli-help'
};
}
2 changes: 1 addition & 1 deletion cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const command = argParser(process.argv.slice(2), {
});

if (command.help || (process.argv.length <= 2 && process.stdin.isTTY)) {
console.log(`\n${help.replace('__VERSION__', version)}\n`);
console.log(`\n${help}\n`);
} else if (command.version) {
console.log(`rollup v${version}`);
} else {
Expand Down
10 changes: 7 additions & 3 deletions cli/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ rollup version __VERSION__

Usage: rollup [options] <entry file>

Basic options:
Options:

// #region options
-c, --config <filename> Use this config file (if argument is used but value
is unspecified, defaults to rollup.config.js)
is unspecified, Rollup will try to load configuration files in
the following order:
rollup.config.mjs -> rollup.config.cjs -> rollup.config.js)
-d, --dir <dirname> Directory for chunks (if absent, prints to stdout)
-e, --external <ids> Comma-separate list of module IDs to exclude
-f, --format <format> Type of output (amd, cjs, es, iife, umd, system)
Expand Down Expand Up @@ -91,7 +94,7 @@ Basic options:
--validate Validate output
--waitForBundleInput Wait for bundle input files
--watch.allowInputInsideOutputPath Whether the input path is allowed to be a
subpath of the output path
subpath of the output path
--watch.buildDelay <number> Throttle watch rebuilds
--no-watch.clearScreen Do not clear the screen when rebuilding
--watch.exclude <files> Exclude files from being watched
Expand All @@ -102,6 +105,7 @@ Basic options:
--watch.onError <cmd> Shell command to run on `"ERROR"` event
--watch.onStart <cmd> Shell command to run on `"START"` event
--watch.skipWrite Do not write files to disk when watching
// #endregion options

Examples:

Expand Down
4 changes: 4 additions & 0 deletions docs/command-line-interface/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ export default {

许多选项都有等效的命令行标志。在这些情况下,如果你正在使用配置文件,则此处传递的任何参数都将覆盖配置文件。以下是所有支持的选项列表:

<<<<<<< HEAD
```
-c, --config <filename> 使用此配置文件
(如果使用参数但未指定值,则默认为 rollup.config.js)
Expand Down Expand Up @@ -472,6 +473,9 @@ export default {
--watch.onStart <cmd> 在 "START" 事件上运行的 Shell 命令
--watch.skipWrite 在监视时不要将文件写入磁盘
```
=======
<<< ../../cli/help.md#options{text}
>>>>>>> fe42b2d7ea3154fbfb23e68a500db55d5f8e2957

以下标志仅通过命令行界面可用。所有其他标志都对应并覆盖其配置文件等效项,请参阅[选项大列表](../configuration-options/index.md)获取详细信息。

Expand Down
Loading
Loading