diff --git a/api-reports/rspeedy.json b/api-reports/rspeedy.json index 9d9c6d8bb..aa58db08f 100644 --- a/api-reports/rspeedy.json +++ b/api-reports/rspeedy.json @@ -37,6 +37,13 @@ } ] }, + { + "text": "progressBar", + "link": "api/rspeedy/rspeedy.dev.progressbar", + "collapsed": true, + "collapsible": false, + "items": [] + }, { "text": "watchFiles", "link": "api/rspeedy/rspeedy.dev.watchfiles", @@ -129,47 +136,12 @@ "collapsed": true, "collapsible": true, "items": [ - { - "text": "css", - "link": "api/rspeedy/rspeedy.distpath.css", - "collapsed": true, - "collapsible": false, - "items": [] - }, - { - "text": "cssAsync", - "link": "api/rspeedy/rspeedy.distpath.cssasync", - "collapsed": true, - "collapsible": false, - "items": [] - }, { "text": "intermediate", "link": "api/rspeedy/rspeedy.distpath.intermediate", "collapsed": true, "collapsible": false, "items": [] - }, - { - "text": "js", - "link": "api/rspeedy/rspeedy.distpath.js", - "collapsed": true, - "collapsible": false, - "items": [] - }, - { - "text": "jsAsync", - "link": "api/rspeedy/rspeedy.distpath.jsasync", - "collapsed": true, - "collapsible": false, - "items": [] - }, - { - "text": "root", - "link": "api/rspeedy/rspeedy.distpath.root", - "collapsed": true, - "collapsible": false, - "items": [] } ] }, @@ -346,6 +318,13 @@ } ] }, + { + "text": "printFileSize", + "link": "api/rspeedy/rspeedy.performance.printfilesize", + "collapsed": true, + "collapsible": false, + "items": [] + }, { "text": "removeConsole", "link": "api/rspeedy/rspeedy.performance.removeconsole", @@ -388,6 +367,13 @@ "collapsed": true, "collapsible": false, "items": [] + }, + { + "text": "strictPort", + "link": "api/rspeedy/rspeedy.server.strictport", + "collapsed": true, + "collapsible": false, + "items": [] } ] }, diff --git a/docs/en/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.extractstr.md b/docs/en/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.extractstr.md new file mode 100644 index 000000000..fcce1ff83 --- /dev/null +++ b/docs/en/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.extractstr.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@lynx-js/react-rsbuild-plugin](./react-rsbuild-plugin.md) > [PluginReactLynxOptions](./react-rsbuild-plugin.pluginreactlynxoptions.md) > [extractStr](./react-rsbuild-plugin.pluginreactlynxoptions.extractstr.md) + +## PluginReactLynxOptions.extractStr property + +Merge same string literals in JS and Lepus to reduce output bundle size. Set to `false` to disable. + +**Signature:** + +```typescript +extractStr?: Partial | boolean; +``` diff --git a/docs/en/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.md b/docs/en/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.md index deb2fb418..6ae4d02b7 100644 --- a/docs/en/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.md +++ b/docs/en/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.md @@ -9,7 +9,7 @@ Options of [pluginReactLynx()](./react-rsbuild-plugin.pluginreactlynx.md) **Signature:** ```typescript -export interface PluginReactLynxOptions +export interface PluginReactLynxOptions ``` ## Properties @@ -32,6 +32,7 @@ export interface PluginReactLynxOptions | [enableSSR?](./react-rsbuild-plugin.pluginreactlynxoptions.enablessr.md) | | boolean | _(Optional)_ enableSSR enable Lynx SSR feature for this build. | | [engineVersion?](./react-rsbuild-plugin.pluginreactlynxoptions.engineversion.md) | | string | _(Optional)_ engineVersion specifies the minimum Lynx Engine version required for an App bundle to function properly. | | [experimental\_isLazyBundle?](./react-rsbuild-plugin.pluginreactlynxoptions.experimental_islazybundle.md) | | boolean | **_(ALPHA)_** _(Optional)_ Generate standalone lazy bundle. | +| [extractStr?](./react-rsbuild-plugin.pluginreactlynxoptions.extractstr.md) | | Partial<ExtractStrConfig> \| boolean | _(Optional)_ Merge same string literals in JS and Lepus to reduce output bundle size. Set to false to disable. | | [firstScreenSyncTiming?](./react-rsbuild-plugin.pluginreactlynxoptions.firstscreensynctiming.md) | | 'immediately' \| 'jsReady' |

_(Optional)_ This flag controls when MainThread (Lepus) transfers control to Background after the first screen

This flag has two options:

"immediately": Transfer immediately

"jsReady": Transfer when background (JS Runtime) is ready

After handing over control, MainThread (Lepus) runtime can no longer respond to data updates, and data updates will be forwarded to background (JS Runtime) and processed \_\_asynchronously\_\_

| | [jsx?](./react-rsbuild-plugin.pluginreactlynxoptions.jsx.md) | | Partial<JsxTransformerConfig> \| undefined | _(Optional)_ The jsx option controls how JSX is transformed. | | [pipelineSchedulerConfig?](./react-rsbuild-plugin.pluginreactlynxoptions.pipelineschedulerconfig.md) | | number | _(Optional)_ Composite configuration representing pipeline scheduling strategies, including [PluginReactLynxOptions.enableParallelElement](./react-rsbuild-plugin.pluginreactlynxoptions.enableparallelelement.md) and list batch-rendering. All newly introduced scheduling strategies will be managed by this uint64 configuration. | diff --git a/docs/en/api/rspeedy/rspeedy.createrspeedy.md b/docs/en/api/rspeedy/rspeedy.createrspeedy.md index 5664ec8c7..4c6b1ee46 100644 --- a/docs/en/api/rspeedy/rspeedy.createrspeedy.md +++ b/docs/en/api/rspeedy/rspeedy.createrspeedy.md @@ -9,14 +9,14 @@ The `createRspeedy` method can let you create a Rspeedy instance and you can cus **Signature:** ```typescript -export declare function createRspeedy({ cwd, rspeedyConfig }: CreateRspeedyOptions): Promise; +export declare function createRspeedy({ cwd, rspeedyConfig, loadEnv }: CreateRspeedyOptions): Promise; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| { cwd, rspeedyConfig } | [CreateRspeedyOptions](./rspeedy.createrspeedyoptions.md) | | +| { cwd, rspeedyConfig, loadEnv } | [CreateRspeedyOptions](./rspeedy.createrspeedyoptions.md) | | **Returns:** diff --git a/docs/en/api/rspeedy/rspeedy.createrspeedyoptions.loadenv.md b/docs/en/api/rspeedy/rspeedy.createrspeedyoptions.loadenv.md new file mode 100644 index 000000000..e324196cc --- /dev/null +++ b/docs/en/api/rspeedy/rspeedy.createrspeedyoptions.loadenv.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@lynx-js/rspeedy](./rspeedy.md) > [CreateRspeedyOptions](./rspeedy.createrspeedyoptions.md) > [loadEnv](./rspeedy.createrspeedyoptions.loadenv.md) + +## CreateRspeedyOptions.loadEnv property + +Rspeedy automatically loads the .env file by default, utilizing the \[Rsbuild API\](https://rsbuild.dev/api/javascript-api/core\#load-env-variables). You can use the environment variables defined in the .env file within your code by accessing them via `import.meta.env.FOO` or `process.env.Foo`. + +**Signature:** + +```typescript +loadEnv?: CreateRsbuildOptions['loadEnv']; +``` diff --git a/docs/en/api/rspeedy/rspeedy.createrspeedyoptions.md b/docs/en/api/rspeedy/rspeedy.createrspeedyoptions.md index 3aa9a7a40..204c9a0b1 100644 --- a/docs/en/api/rspeedy/rspeedy.createrspeedyoptions.md +++ b/docs/en/api/rspeedy/rspeedy.createrspeedyoptions.md @@ -17,5 +17,6 @@ export interface CreateRspeedyOptions | Property | Modifiers | Type | Description | | --- | --- | --- | --- | | [cwd?](./rspeedy.createrspeedyoptions.cwd.md) | | string | _(Optional)_ The root path of the current build. | +| [loadEnv?](./rspeedy.createrspeedyoptions.loadenv.md) | | CreateRsbuildOptions\['loadEnv'\] | _(Optional)_ Rspeedy automatically loads the .env file by default, utilizing the \[Rsbuild API\](https://rsbuild.dev/api/javascript-api/core\#load-env-variables). You can use the environment variables defined in the .env file within your code by accessing them via import.meta.env.FOO or process.env.Foo. | | [rspeedyConfig?](./rspeedy.createrspeedyoptions.rspeedyconfig.md) | | [Config](./rspeedy.config.md) | _(Optional)_ The config of Rspeedy. | diff --git a/docs/en/api/rspeedy/rspeedy.dev.md b/docs/en/api/rspeedy/rspeedy.dev.md index 4a195fc0e..98c974c9e 100644 --- a/docs/en/api/rspeedy/rspeedy.dev.md +++ b/docs/en/api/rspeedy/rspeedy.dev.md @@ -18,6 +18,7 @@ export interface Dev | --- | --- | --- | --- | | [assetPrefix?](./rspeedy.dev.assetprefix.md) | | string \| boolean \| undefined | _(Optional)_ The [Dev.assetPrefix](./rspeedy.dev.assetprefix.md) is used to set the URL prefix for static assets during development. | | [client?](./rspeedy.dev.client.md) | | [Client](./rspeedy.devclient.md) \| undefined | _(Optional)_ Configuration of the development client. | +| [progressBar?](./rspeedy.dev.progressbar.md) | | boolean \| { id?: string; } \| undefined |

_(Optional)_ Whether to display progress bar during compilation.

Defaults to true.

| | [watchFiles?](./rspeedy.dev.watchfiles.md) | | WatchFiles \| WatchFiles\[\] \| undefined | _(Optional)_ Watch specified files and directories for changes. When a file change is detected, it can trigger a page reload or restart the dev server. | | [writeToDisk?](./rspeedy.dev.writetodisk.md) | | boolean \| ((filename: string) => boolean) \| undefined | _(Optional)_ Used to control whether the build artifacts of the development environment are written to the disk. | diff --git a/docs/en/api/rspeedy/rspeedy.dev.progressbar.md b/docs/en/api/rspeedy/rspeedy.dev.progressbar.md new file mode 100644 index 000000000..9ccc70c79 --- /dev/null +++ b/docs/en/api/rspeedy/rspeedy.dev.progressbar.md @@ -0,0 +1,50 @@ + + +[Home](./index.md) > [@lynx-js/rspeedy](./rspeedy.md) > [Dev](./rspeedy.dev.md) > [progressBar](./rspeedy.dev.progressbar.md) + +## Dev.progressBar property + +Whether to display progress bar during compilation. + +Defaults to `true`. + +**Signature:** + +```typescript +progressBar?: boolean | { + id?: string; + } | undefined; +``` + +## Example 1 + +Disable the progress bar. + +```js +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + dev: { + progressBar: false, + }, +}) +``` + +## Example 2 + +Modify the progress bar `id` + +To modify the text displayed on the left side of the progress bar, set the `id` option: + +```js +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + dev: { + progressBar: { + id: 'Some Text' + }, + }, +}) +``` + diff --git a/docs/en/api/rspeedy/rspeedy.distpath.md b/docs/en/api/rspeedy/rspeedy.distpath.md index 1b6ba5a68..de5f7a9e6 100644 --- a/docs/en/api/rspeedy/rspeedy.distpath.md +++ b/docs/en/api/rspeedy/rspeedy.distpath.md @@ -9,17 +9,17 @@ Set the directory of the dist files. **Signature:** ```typescript -export interface DistPath +export interface DistPath extends DistPathConfig ``` +**Extends:** DistPathConfig + +## Remarks + +More options can be found at [Rsbuild - distPath](https://rsbuild.dev/config/output/dist-path). ## Properties | Property | Modifiers | Type | Description | | --- | --- | --- | --- | -| [css?](./rspeedy.distpath.css.md) | | string \| undefined | _(Optional)_ The output directory of CSS style files. | -| [cssAsync?](./rspeedy.distpath.cssasync.md) | | string \| undefined | _(Optional)_ The output directory of async JavaScript files. | | [intermediate?](./rspeedy.distpath.intermediate.md) | | string \| undefined | _(Optional)_ The output directory of the intermediate files. | -| [js?](./rspeedy.distpath.js.md) | | string \| undefined | _(Optional)_ The output directory of JavaScript files. | -| [jsAsync?](./rspeedy.distpath.jsasync.md) | | string \| undefined | _(Optional)_ The output directory of async JavaScript files. | -| [root?](./rspeedy.distpath.root.md) | | string \| undefined | _(Optional)_ The root directory of all output files. | diff --git a/docs/en/api/rspeedy/rspeedy.md b/docs/en/api/rspeedy/rspeedy.md index 2f1a8a2ef..a6143fdf2 100644 --- a/docs/en/api/rspeedy/rspeedy.md +++ b/docs/en/api/rspeedy/rspeedy.md @@ -21,7 +21,7 @@ export default defineConfig({ | Function | Description | | --- | --- | -| [createRspeedy({ cwd, rspeedyConfig })](./rspeedy.createrspeedy.md) | The createRspeedy method can let you create a Rspeedy instance and you can customize the build or development process in Node.js Runtime. | +| [createRspeedy({ cwd, rspeedyConfig, loadEnv })](./rspeedy.createrspeedy.md) | The createRspeedy method can let you create a Rspeedy instance and you can customize the build or development process in Node.js Runtime. | | [defineConfig(config)](./rspeedy.defineconfig.md) | The defineConfig method is a helper function used to get TypeScript intellisense. | | [loadConfig(loadConfigOptions)](./rspeedy.loadconfig.md) | Load the build config by the config path. | | [mergeRspeedyConfig(configs)](./rspeedy.mergerspeedyconfig.md) | Merge multiple Rspeedy configuration objects. | diff --git a/docs/en/api/rspeedy/rspeedy.output.cleandistpath.md b/docs/en/api/rspeedy/rspeedy.output.cleandistpath.md index 701ee4d4b..4bceb0d8e 100644 --- a/docs/en/api/rspeedy/rspeedy.output.cleandistpath.md +++ b/docs/en/api/rspeedy/rspeedy.output.cleandistpath.md @@ -16,7 +16,7 @@ cleanDistPath?: boolean | undefined; By default, if the output directory is a subdirectory of the project root path, Rspeedy will automatically clean all files in the build directory. -When [output.distPath.root](./rspeedy.distpath.root.md) is an external directory or the same as the project root directory, `cleanDistPath` is not enabled by default to prevent accidental deletion of files from other directories. +When [output.distPath.root](https://rsbuild.dev/config/output/dist-path#root-directory) is an external directory or the same as the project root directory, `cleanDistPath` is not enabled by default to prevent accidental deletion of files from other directories. ## Example 1 diff --git a/docs/en/api/rspeedy/rspeedy.output.distpath.md b/docs/en/api/rspeedy/rspeedy.output.distpath.md index 993f9329a..0413c483e 100644 --- a/docs/en/api/rspeedy/rspeedy.output.distpath.md +++ b/docs/en/api/rspeedy/rspeedy.output.distpath.md @@ -12,6 +12,10 @@ Set the directory of the dist files. distPath?: DistPath | undefined; ``` +## Remarks + +More options can be found at [Rsbuild - distPath](https://rsbuild.dev/config/output/dist-path). + ## Example Use `output` instead of `dist`(the default value): diff --git a/docs/en/api/rspeedy/rspeedy.performance.md b/docs/en/api/rspeedy/rspeedy.performance.md index 2d24f5df6..eccc94191 100644 --- a/docs/en/api/rspeedy/rspeedy.performance.md +++ b/docs/en/api/rspeedy/rspeedy.performance.md @@ -17,5 +17,6 @@ export interface Performance | Property | Modifiers | Type | Description | | --- | --- | --- | --- | | [chunkSplit?](./rspeedy.performance.chunksplit.md) | | [ChunkSplit](./rspeedy.chunksplit.md) \| [ChunkSplitBySize](./rspeedy.chunksplitbysize.md) \| [ChunkSplitCustom](./rspeedy.chunksplitcustom.md) \| undefined | _(Optional)_ [Performance.chunkSplit](./rspeedy.performance.chunksplit.md) is used to configure the chunk splitting strategy. | +| [printFileSize?](./rspeedy.performance.printfilesize.md) | | PerformanceConfig\['printFileSize'\] \| undefined |

_(Optional)_ Whether to print the file sizes after production build.

[Performance.printFileSize](./rspeedy.performance.printfilesize.md)

See [Rsbuild - performance.printFileSize](https://rsbuild.dev/config/performance/print-file-size) for details.

| | [removeConsole?](./rspeedy.performance.removeconsole.md) | | boolean \| [ConsoleType](./rspeedy.consoletype.md)\[\] \| undefined | _(Optional)_ Whether to remove console.[methodName] in production build. | diff --git a/docs/en/api/rspeedy/rspeedy.performance.printfilesize.md b/docs/en/api/rspeedy/rspeedy.performance.printfilesize.md new file mode 100644 index 000000000..049498c2d --- /dev/null +++ b/docs/en/api/rspeedy/rspeedy.performance.printfilesize.md @@ -0,0 +1,124 @@ + + +[Home](./index.md) > [@lynx-js/rspeedy](./rspeedy.md) > [Performance](./rspeedy.performance.md) > [printFileSize](./rspeedy.performance.printfilesize.md) + +## Performance.printFileSize property + +Whether to print the file sizes after production build. + +[Performance.printFileSize](./rspeedy.performance.printfilesize.md) + +See [Rsbuild - performance.printFileSize](https://rsbuild.dev/config/performance/print-file-size) for details. + +**Signature:** + +```typescript +printFileSize?: PerformanceConfig['printFileSize'] | undefined; +``` + +## Example 1 + +If you don't want to print any information, you can disable it by setting printFileSize to false: + +```ts +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + performance: { + printFileSize: false + }, +}) +``` + +## Example 2 + +Set total to false to disable total size output. + +```ts +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + performance: { + printFileSize: { + total: false, + }, + }, +}) +``` + +## Example 3 + +Set detail to false to disable per-asset size output. + +If you don't need to view the size of each static asset, you can set detail to false. In this case, only the total size will be output: + +```ts +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + performance: { + printFileSize: { + detail: false, + }, + }, +}) +``` + +## Example 4 + +If you don't need to view the gzipped size, you can set compressed to false. This can save some gzip computation time for large projects: + +```ts +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + performance: { + printFileSize: { + compressed: false, + }, + }, +}) +``` + +## Example 5 + +To include only static assets that meet certain criteria, use a filter function with include. + +If returned false, the static asset will be excluded and not included in the total size or detailed size. + +only output static assets larger than 10kB: + +```ts +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + performance: { + printFileSize: { + include: (asset) => asset.size > 10 * 1000, + } + }, +}) +``` + +## Example 6 + +To exclude static assets that meet certain criteria, use a filter function with exclude. If both include and exclude are set, exclude will take precedence. + +Rspeedy defaults to excluding source map, license files, and .d.ts type files, as these files do not affect page load performance. + +exclude .html files in addition to the default: + +```ts +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + performance: { + printFileSize: { + exclude: (asset) => + /\.(?:map|LICENSE\.txt)$/.test(asset.name) || + /\.html$/.test(asset.name), + } + }, +}) +``` + diff --git a/docs/en/api/rspeedy/rspeedy.server.host.md b/docs/en/api/rspeedy/rspeedy.server.host.md index 948ca4734..ae4293219 100644 --- a/docs/en/api/rspeedy/rspeedy.server.host.md +++ b/docs/en/api/rspeedy/rspeedy.server.host.md @@ -11,3 +11,21 @@ Specify the host that the Rspeedy Server listens to. ```typescript host?: string | undefined; ``` + +## Remarks + +By default, the server listens on local network IP, for example, `192.168.1.50`, verify your local net IP by the command `ifconfig` on your system for (en0 for MacOS and eth0 for LinuxOS users). In case you have multiple local network IP(s) particularly when you are running dockers on the host machine, then you can specify your desired host IP. + +## Example + +Set the host to a custom value: + +```js +import { defineConfig } from '@lynx-js/rspeedy' +export default defineConfig({ + server: { + host: "192.168.1.50", + }, +}) +``` + diff --git a/docs/en/api/rspeedy/rspeedy.server.md b/docs/en/api/rspeedy/rspeedy.server.md index a2a2c804b..fa278096e 100644 --- a/docs/en/api/rspeedy/rspeedy.server.md +++ b/docs/en/api/rspeedy/rspeedy.server.md @@ -20,4 +20,5 @@ export interface Server | [headers?](./rspeedy.server.headers.md) | | Record<string, string \| string\[\]> \| undefined | _(Optional)_ Adds headers to all responses. | | [host?](./rspeedy.server.host.md) | | string \| undefined | _(Optional)_ Specify the host that the Rspeedy Server listens to. | | [port?](./rspeedy.server.port.md) | | number \| undefined | _(Optional)_ Specify the port that the Rspeedy Server listens to. | +| [strictPort?](./rspeedy.server.strictport.md) | | boolean \| undefined |

_(Optional)_ When a port is occupied, Rspeedy will automatically increment the port number until an available port is found.

Set strictPort to true and Rspeedy will throw an exception when the port is occupied.

| diff --git a/docs/en/api/rspeedy/rspeedy.server.strictport.md b/docs/en/api/rspeedy/rspeedy.server.strictport.md new file mode 100644 index 000000000..2b143cbb4 --- /dev/null +++ b/docs/en/api/rspeedy/rspeedy.server.strictport.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@lynx-js/rspeedy](./rspeedy.md) > [Server](./rspeedy.server.md) > [strictPort](./rspeedy.server.strictport.md) + +## Server.strictPort property + +When a port is occupied, Rspeedy will automatically increment the port number until an available port is found. + +Set strictPort to true and Rspeedy will throw an exception when the port is occupied. + +**Signature:** + +```typescript +strictPort?: boolean | undefined; +``` diff --git a/docs/en/api/rspeedy/rspeedy.sourcemap.js.md b/docs/en/api/rspeedy/rspeedy.sourcemap.js.md index 21ef5f159..ec5caa079 100644 --- a/docs/en/api/rspeedy/rspeedy.sourcemap.js.md +++ b/docs/en/api/rspeedy/rspeedy.sourcemap.js.md @@ -9,7 +9,7 @@ How the source map should be generated. Setting it to `false` will disable the s **Signature:** ```typescript -js?: Rspack.DevTool | undefined; +js?: Rspack.DevTool | undefined | `${Exclude}-debugids`; ``` ## Remarks diff --git a/docs/en/api/rspeedy/rspeedy.sourcemap.md b/docs/en/api/rspeedy/rspeedy.sourcemap.md index 9b4a7d08d..b80a4193f 100644 --- a/docs/en/api/rspeedy/rspeedy.sourcemap.md +++ b/docs/en/api/rspeedy/rspeedy.sourcemap.md @@ -16,5 +16,5 @@ export interface SourceMap | Property | Modifiers | Type | Description | | --- | --- | --- | --- | -| [js?](./rspeedy.sourcemap.js.md) | | Rspack.DevTool \| undefined | _(Optional)_ How the source map should be generated. Setting it to false will disable the source map. | +| [js?](./rspeedy.sourcemap.js.md) | | Rspack.DevTool \| undefined \| \`${Exclude<Rspack.DevTool, false \| 'eval'>}-debugids\` | _(Optional)_ How the source map should be generated. Setting it to false will disable the source map. | diff --git a/docs/zh/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.extractstr.md b/docs/zh/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.extractstr.md new file mode 100644 index 000000000..fcce1ff83 --- /dev/null +++ b/docs/zh/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.extractstr.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@lynx-js/react-rsbuild-plugin](./react-rsbuild-plugin.md) > [PluginReactLynxOptions](./react-rsbuild-plugin.pluginreactlynxoptions.md) > [extractStr](./react-rsbuild-plugin.pluginreactlynxoptions.extractstr.md) + +## PluginReactLynxOptions.extractStr property + +Merge same string literals in JS and Lepus to reduce output bundle size. Set to `false` to disable. + +**Signature:** + +```typescript +extractStr?: Partial | boolean; +``` diff --git a/docs/zh/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.md b/docs/zh/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.md index deb2fb418..6ae4d02b7 100644 --- a/docs/zh/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.md +++ b/docs/zh/api/rspeedy/react-rsbuild-plugin.pluginreactlynxoptions.md @@ -9,7 +9,7 @@ Options of [pluginReactLynx()](./react-rsbuild-plugin.pluginreactlynx.md) **Signature:** ```typescript -export interface PluginReactLynxOptions +export interface PluginReactLynxOptions ``` ## Properties @@ -32,6 +32,7 @@ export interface PluginReactLynxOptions | [enableSSR?](./react-rsbuild-plugin.pluginreactlynxoptions.enablessr.md) | | boolean | _(Optional)_ enableSSR enable Lynx SSR feature for this build. | | [engineVersion?](./react-rsbuild-plugin.pluginreactlynxoptions.engineversion.md) | | string | _(Optional)_ engineVersion specifies the minimum Lynx Engine version required for an App bundle to function properly. | | [experimental\_isLazyBundle?](./react-rsbuild-plugin.pluginreactlynxoptions.experimental_islazybundle.md) | | boolean | **_(ALPHA)_** _(Optional)_ Generate standalone lazy bundle. | +| [extractStr?](./react-rsbuild-plugin.pluginreactlynxoptions.extractstr.md) | | Partial<ExtractStrConfig> \| boolean | _(Optional)_ Merge same string literals in JS and Lepus to reduce output bundle size. Set to false to disable. | | [firstScreenSyncTiming?](./react-rsbuild-plugin.pluginreactlynxoptions.firstscreensynctiming.md) | | 'immediately' \| 'jsReady' |

_(Optional)_ This flag controls when MainThread (Lepus) transfers control to Background after the first screen

This flag has two options:

"immediately": Transfer immediately

"jsReady": Transfer when background (JS Runtime) is ready

After handing over control, MainThread (Lepus) runtime can no longer respond to data updates, and data updates will be forwarded to background (JS Runtime) and processed \_\_asynchronously\_\_

| | [jsx?](./react-rsbuild-plugin.pluginreactlynxoptions.jsx.md) | | Partial<JsxTransformerConfig> \| undefined | _(Optional)_ The jsx option controls how JSX is transformed. | | [pipelineSchedulerConfig?](./react-rsbuild-plugin.pluginreactlynxoptions.pipelineschedulerconfig.md) | | number | _(Optional)_ Composite configuration representing pipeline scheduling strategies, including [PluginReactLynxOptions.enableParallelElement](./react-rsbuild-plugin.pluginreactlynxoptions.enableparallelelement.md) and list batch-rendering. All newly introduced scheduling strategies will be managed by this uint64 configuration. | diff --git a/docs/zh/api/rspeedy/rspeedy.createrspeedy.md b/docs/zh/api/rspeedy/rspeedy.createrspeedy.md index 5664ec8c7..4c6b1ee46 100644 --- a/docs/zh/api/rspeedy/rspeedy.createrspeedy.md +++ b/docs/zh/api/rspeedy/rspeedy.createrspeedy.md @@ -9,14 +9,14 @@ The `createRspeedy` method can let you create a Rspeedy instance and you can cus **Signature:** ```typescript -export declare function createRspeedy({ cwd, rspeedyConfig }: CreateRspeedyOptions): Promise; +export declare function createRspeedy({ cwd, rspeedyConfig, loadEnv }: CreateRspeedyOptions): Promise; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| { cwd, rspeedyConfig } | [CreateRspeedyOptions](./rspeedy.createrspeedyoptions.md) | | +| { cwd, rspeedyConfig, loadEnv } | [CreateRspeedyOptions](./rspeedy.createrspeedyoptions.md) | | **Returns:** diff --git a/docs/zh/api/rspeedy/rspeedy.createrspeedyoptions.loadenv.md b/docs/zh/api/rspeedy/rspeedy.createrspeedyoptions.loadenv.md new file mode 100644 index 000000000..e324196cc --- /dev/null +++ b/docs/zh/api/rspeedy/rspeedy.createrspeedyoptions.loadenv.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@lynx-js/rspeedy](./rspeedy.md) > [CreateRspeedyOptions](./rspeedy.createrspeedyoptions.md) > [loadEnv](./rspeedy.createrspeedyoptions.loadenv.md) + +## CreateRspeedyOptions.loadEnv property + +Rspeedy automatically loads the .env file by default, utilizing the \[Rsbuild API\](https://rsbuild.dev/api/javascript-api/core\#load-env-variables). You can use the environment variables defined in the .env file within your code by accessing them via `import.meta.env.FOO` or `process.env.Foo`. + +**Signature:** + +```typescript +loadEnv?: CreateRsbuildOptions['loadEnv']; +``` diff --git a/docs/zh/api/rspeedy/rspeedy.createrspeedyoptions.md b/docs/zh/api/rspeedy/rspeedy.createrspeedyoptions.md index 3aa9a7a40..204c9a0b1 100644 --- a/docs/zh/api/rspeedy/rspeedy.createrspeedyoptions.md +++ b/docs/zh/api/rspeedy/rspeedy.createrspeedyoptions.md @@ -17,5 +17,6 @@ export interface CreateRspeedyOptions | Property | Modifiers | Type | Description | | --- | --- | --- | --- | | [cwd?](./rspeedy.createrspeedyoptions.cwd.md) | | string | _(Optional)_ The root path of the current build. | +| [loadEnv?](./rspeedy.createrspeedyoptions.loadenv.md) | | CreateRsbuildOptions\['loadEnv'\] | _(Optional)_ Rspeedy automatically loads the .env file by default, utilizing the \[Rsbuild API\](https://rsbuild.dev/api/javascript-api/core\#load-env-variables). You can use the environment variables defined in the .env file within your code by accessing them via import.meta.env.FOO or process.env.Foo. | | [rspeedyConfig?](./rspeedy.createrspeedyoptions.rspeedyconfig.md) | | [Config](./rspeedy.config.md) | _(Optional)_ The config of Rspeedy. | diff --git a/docs/zh/api/rspeedy/rspeedy.dev.md b/docs/zh/api/rspeedy/rspeedy.dev.md index 4a195fc0e..98c974c9e 100644 --- a/docs/zh/api/rspeedy/rspeedy.dev.md +++ b/docs/zh/api/rspeedy/rspeedy.dev.md @@ -18,6 +18,7 @@ export interface Dev | --- | --- | --- | --- | | [assetPrefix?](./rspeedy.dev.assetprefix.md) | | string \| boolean \| undefined | _(Optional)_ The [Dev.assetPrefix](./rspeedy.dev.assetprefix.md) is used to set the URL prefix for static assets during development. | | [client?](./rspeedy.dev.client.md) | | [Client](./rspeedy.devclient.md) \| undefined | _(Optional)_ Configuration of the development client. | +| [progressBar?](./rspeedy.dev.progressbar.md) | | boolean \| { id?: string; } \| undefined |

_(Optional)_ Whether to display progress bar during compilation.

Defaults to true.

| | [watchFiles?](./rspeedy.dev.watchfiles.md) | | WatchFiles \| WatchFiles\[\] \| undefined | _(Optional)_ Watch specified files and directories for changes. When a file change is detected, it can trigger a page reload or restart the dev server. | | [writeToDisk?](./rspeedy.dev.writetodisk.md) | | boolean \| ((filename: string) => boolean) \| undefined | _(Optional)_ Used to control whether the build artifacts of the development environment are written to the disk. | diff --git a/docs/zh/api/rspeedy/rspeedy.dev.progressbar.md b/docs/zh/api/rspeedy/rspeedy.dev.progressbar.md new file mode 100644 index 000000000..9ccc70c79 --- /dev/null +++ b/docs/zh/api/rspeedy/rspeedy.dev.progressbar.md @@ -0,0 +1,50 @@ + + +[Home](./index.md) > [@lynx-js/rspeedy](./rspeedy.md) > [Dev](./rspeedy.dev.md) > [progressBar](./rspeedy.dev.progressbar.md) + +## Dev.progressBar property + +Whether to display progress bar during compilation. + +Defaults to `true`. + +**Signature:** + +```typescript +progressBar?: boolean | { + id?: string; + } | undefined; +``` + +## Example 1 + +Disable the progress bar. + +```js +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + dev: { + progressBar: false, + }, +}) +``` + +## Example 2 + +Modify the progress bar `id` + +To modify the text displayed on the left side of the progress bar, set the `id` option: + +```js +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + dev: { + progressBar: { + id: 'Some Text' + }, + }, +}) +``` + diff --git a/docs/zh/api/rspeedy/rspeedy.distpath.md b/docs/zh/api/rspeedy/rspeedy.distpath.md index 1b6ba5a68..de5f7a9e6 100644 --- a/docs/zh/api/rspeedy/rspeedy.distpath.md +++ b/docs/zh/api/rspeedy/rspeedy.distpath.md @@ -9,17 +9,17 @@ Set the directory of the dist files. **Signature:** ```typescript -export interface DistPath +export interface DistPath extends DistPathConfig ``` +**Extends:** DistPathConfig + +## Remarks + +More options can be found at [Rsbuild - distPath](https://rsbuild.dev/config/output/dist-path). ## Properties | Property | Modifiers | Type | Description | | --- | --- | --- | --- | -| [css?](./rspeedy.distpath.css.md) | | string \| undefined | _(Optional)_ The output directory of CSS style files. | -| [cssAsync?](./rspeedy.distpath.cssasync.md) | | string \| undefined | _(Optional)_ The output directory of async JavaScript files. | | [intermediate?](./rspeedy.distpath.intermediate.md) | | string \| undefined | _(Optional)_ The output directory of the intermediate files. | -| [js?](./rspeedy.distpath.js.md) | | string \| undefined | _(Optional)_ The output directory of JavaScript files. | -| [jsAsync?](./rspeedy.distpath.jsasync.md) | | string \| undefined | _(Optional)_ The output directory of async JavaScript files. | -| [root?](./rspeedy.distpath.root.md) | | string \| undefined | _(Optional)_ The root directory of all output files. | diff --git a/docs/zh/api/rspeedy/rspeedy.md b/docs/zh/api/rspeedy/rspeedy.md index 2f1a8a2ef..a6143fdf2 100644 --- a/docs/zh/api/rspeedy/rspeedy.md +++ b/docs/zh/api/rspeedy/rspeedy.md @@ -21,7 +21,7 @@ export default defineConfig({ | Function | Description | | --- | --- | -| [createRspeedy({ cwd, rspeedyConfig })](./rspeedy.createrspeedy.md) | The createRspeedy method can let you create a Rspeedy instance and you can customize the build or development process in Node.js Runtime. | +| [createRspeedy({ cwd, rspeedyConfig, loadEnv })](./rspeedy.createrspeedy.md) | The createRspeedy method can let you create a Rspeedy instance and you can customize the build or development process in Node.js Runtime. | | [defineConfig(config)](./rspeedy.defineconfig.md) | The defineConfig method is a helper function used to get TypeScript intellisense. | | [loadConfig(loadConfigOptions)](./rspeedy.loadconfig.md) | Load the build config by the config path. | | [mergeRspeedyConfig(configs)](./rspeedy.mergerspeedyconfig.md) | Merge multiple Rspeedy configuration objects. | diff --git a/docs/zh/api/rspeedy/rspeedy.output.cleandistpath.md b/docs/zh/api/rspeedy/rspeedy.output.cleandistpath.md index 701ee4d4b..4bceb0d8e 100644 --- a/docs/zh/api/rspeedy/rspeedy.output.cleandistpath.md +++ b/docs/zh/api/rspeedy/rspeedy.output.cleandistpath.md @@ -16,7 +16,7 @@ cleanDistPath?: boolean | undefined; By default, if the output directory is a subdirectory of the project root path, Rspeedy will automatically clean all files in the build directory. -When [output.distPath.root](./rspeedy.distpath.root.md) is an external directory or the same as the project root directory, `cleanDistPath` is not enabled by default to prevent accidental deletion of files from other directories. +When [output.distPath.root](https://rsbuild.dev/config/output/dist-path#root-directory) is an external directory or the same as the project root directory, `cleanDistPath` is not enabled by default to prevent accidental deletion of files from other directories. ## Example 1 diff --git a/docs/zh/api/rspeedy/rspeedy.output.distpath.md b/docs/zh/api/rspeedy/rspeedy.output.distpath.md index 993f9329a..0413c483e 100644 --- a/docs/zh/api/rspeedy/rspeedy.output.distpath.md +++ b/docs/zh/api/rspeedy/rspeedy.output.distpath.md @@ -12,6 +12,10 @@ Set the directory of the dist files. distPath?: DistPath | undefined; ``` +## Remarks + +More options can be found at [Rsbuild - distPath](https://rsbuild.dev/config/output/dist-path). + ## Example Use `output` instead of `dist`(the default value): diff --git a/docs/zh/api/rspeedy/rspeedy.performance.md b/docs/zh/api/rspeedy/rspeedy.performance.md index 2d24f5df6..eccc94191 100644 --- a/docs/zh/api/rspeedy/rspeedy.performance.md +++ b/docs/zh/api/rspeedy/rspeedy.performance.md @@ -17,5 +17,6 @@ export interface Performance | Property | Modifiers | Type | Description | | --- | --- | --- | --- | | [chunkSplit?](./rspeedy.performance.chunksplit.md) | | [ChunkSplit](./rspeedy.chunksplit.md) \| [ChunkSplitBySize](./rspeedy.chunksplitbysize.md) \| [ChunkSplitCustom](./rspeedy.chunksplitcustom.md) \| undefined | _(Optional)_ [Performance.chunkSplit](./rspeedy.performance.chunksplit.md) is used to configure the chunk splitting strategy. | +| [printFileSize?](./rspeedy.performance.printfilesize.md) | | PerformanceConfig\['printFileSize'\] \| undefined |

_(Optional)_ Whether to print the file sizes after production build.

[Performance.printFileSize](./rspeedy.performance.printfilesize.md)

See [Rsbuild - performance.printFileSize](https://rsbuild.dev/config/performance/print-file-size) for details.

| | [removeConsole?](./rspeedy.performance.removeconsole.md) | | boolean \| [ConsoleType](./rspeedy.consoletype.md)\[\] \| undefined | _(Optional)_ Whether to remove console.[methodName] in production build. | diff --git a/docs/zh/api/rspeedy/rspeedy.performance.printfilesize.md b/docs/zh/api/rspeedy/rspeedy.performance.printfilesize.md new file mode 100644 index 000000000..049498c2d --- /dev/null +++ b/docs/zh/api/rspeedy/rspeedy.performance.printfilesize.md @@ -0,0 +1,124 @@ + + +[Home](./index.md) > [@lynx-js/rspeedy](./rspeedy.md) > [Performance](./rspeedy.performance.md) > [printFileSize](./rspeedy.performance.printfilesize.md) + +## Performance.printFileSize property + +Whether to print the file sizes after production build. + +[Performance.printFileSize](./rspeedy.performance.printfilesize.md) + +See [Rsbuild - performance.printFileSize](https://rsbuild.dev/config/performance/print-file-size) for details. + +**Signature:** + +```typescript +printFileSize?: PerformanceConfig['printFileSize'] | undefined; +``` + +## Example 1 + +If you don't want to print any information, you can disable it by setting printFileSize to false: + +```ts +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + performance: { + printFileSize: false + }, +}) +``` + +## Example 2 + +Set total to false to disable total size output. + +```ts +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + performance: { + printFileSize: { + total: false, + }, + }, +}) +``` + +## Example 3 + +Set detail to false to disable per-asset size output. + +If you don't need to view the size of each static asset, you can set detail to false. In this case, only the total size will be output: + +```ts +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + performance: { + printFileSize: { + detail: false, + }, + }, +}) +``` + +## Example 4 + +If you don't need to view the gzipped size, you can set compressed to false. This can save some gzip computation time for large projects: + +```ts +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + performance: { + printFileSize: { + compressed: false, + }, + }, +}) +``` + +## Example 5 + +To include only static assets that meet certain criteria, use a filter function with include. + +If returned false, the static asset will be excluded and not included in the total size or detailed size. + +only output static assets larger than 10kB: + +```ts +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + performance: { + printFileSize: { + include: (asset) => asset.size > 10 * 1000, + } + }, +}) +``` + +## Example 6 + +To exclude static assets that meet certain criteria, use a filter function with exclude. If both include and exclude are set, exclude will take precedence. + +Rspeedy defaults to excluding source map, license files, and .d.ts type files, as these files do not affect page load performance. + +exclude .html files in addition to the default: + +```ts +import { defineConfig } from '@lynx-js/rspeedy' + +export default defineConfig({ + performance: { + printFileSize: { + exclude: (asset) => + /\.(?:map|LICENSE\.txt)$/.test(asset.name) || + /\.html$/.test(asset.name), + } + }, +}) +``` + diff --git a/docs/zh/api/rspeedy/rspeedy.server.host.md b/docs/zh/api/rspeedy/rspeedy.server.host.md index 948ca4734..ae4293219 100644 --- a/docs/zh/api/rspeedy/rspeedy.server.host.md +++ b/docs/zh/api/rspeedy/rspeedy.server.host.md @@ -11,3 +11,21 @@ Specify the host that the Rspeedy Server listens to. ```typescript host?: string | undefined; ``` + +## Remarks + +By default, the server listens on local network IP, for example, `192.168.1.50`, verify your local net IP by the command `ifconfig` on your system for (en0 for MacOS and eth0 for LinuxOS users). In case you have multiple local network IP(s) particularly when you are running dockers on the host machine, then you can specify your desired host IP. + +## Example + +Set the host to a custom value: + +```js +import { defineConfig } from '@lynx-js/rspeedy' +export default defineConfig({ + server: { + host: "192.168.1.50", + }, +}) +``` + diff --git a/docs/zh/api/rspeedy/rspeedy.server.md b/docs/zh/api/rspeedy/rspeedy.server.md index a2a2c804b..fa278096e 100644 --- a/docs/zh/api/rspeedy/rspeedy.server.md +++ b/docs/zh/api/rspeedy/rspeedy.server.md @@ -20,4 +20,5 @@ export interface Server | [headers?](./rspeedy.server.headers.md) | | Record<string, string \| string\[\]> \| undefined | _(Optional)_ Adds headers to all responses. | | [host?](./rspeedy.server.host.md) | | string \| undefined | _(Optional)_ Specify the host that the Rspeedy Server listens to. | | [port?](./rspeedy.server.port.md) | | number \| undefined | _(Optional)_ Specify the port that the Rspeedy Server listens to. | +| [strictPort?](./rspeedy.server.strictport.md) | | boolean \| undefined |

_(Optional)_ When a port is occupied, Rspeedy will automatically increment the port number until an available port is found.

Set strictPort to true and Rspeedy will throw an exception when the port is occupied.

| diff --git a/docs/zh/api/rspeedy/rspeedy.server.strictport.md b/docs/zh/api/rspeedy/rspeedy.server.strictport.md new file mode 100644 index 000000000..2b143cbb4 --- /dev/null +++ b/docs/zh/api/rspeedy/rspeedy.server.strictport.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@lynx-js/rspeedy](./rspeedy.md) > [Server](./rspeedy.server.md) > [strictPort](./rspeedy.server.strictport.md) + +## Server.strictPort property + +When a port is occupied, Rspeedy will automatically increment the port number until an available port is found. + +Set strictPort to true and Rspeedy will throw an exception when the port is occupied. + +**Signature:** + +```typescript +strictPort?: boolean | undefined; +``` diff --git a/docs/zh/api/rspeedy/rspeedy.sourcemap.js.md b/docs/zh/api/rspeedy/rspeedy.sourcemap.js.md index 21ef5f159..ec5caa079 100644 --- a/docs/zh/api/rspeedy/rspeedy.sourcemap.js.md +++ b/docs/zh/api/rspeedy/rspeedy.sourcemap.js.md @@ -9,7 +9,7 @@ How the source map should be generated. Setting it to `false` will disable the s **Signature:** ```typescript -js?: Rspack.DevTool | undefined; +js?: Rspack.DevTool | undefined | `${Exclude}-debugids`; ``` ## Remarks diff --git a/docs/zh/api/rspeedy/rspeedy.sourcemap.md b/docs/zh/api/rspeedy/rspeedy.sourcemap.md index 9b4a7d08d..b80a4193f 100644 --- a/docs/zh/api/rspeedy/rspeedy.sourcemap.md +++ b/docs/zh/api/rspeedy/rspeedy.sourcemap.md @@ -16,5 +16,5 @@ export interface SourceMap | Property | Modifiers | Type | Description | | --- | --- | --- | --- | -| [js?](./rspeedy.sourcemap.js.md) | | Rspack.DevTool \| undefined | _(Optional)_ How the source map should be generated. Setting it to false will disable the source map. | +| [js?](./rspeedy.sourcemap.js.md) | | Rspack.DevTool \| undefined \| \`${Exclude<Rspack.DevTool, false \| 'eval'>}-debugids\` | _(Optional)_ How the source map should be generated. Setting it to false will disable the source map. |