For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/packages/rsbuild-plugin/index.md.
Lynx
  • 简体中文
  • 模块: @lynx-js/rsbuild-plugin

    npm · Source · Changelog

    作为 Rsbuild 插件的 Lynx 构建引擎。它直接使用 Rsbuild CLI 构建 Lynx 应用,而无需使用 Rspeedy CLI。

    像 pluginReactLynx 这样的 DSL 插件, 会在引擎缺失时自动注册,因此你只需要自行添加 pluginLynx 来传入下面这些选项。Rspeedy 也会为你注册该引擎, 并从 lynx.config.ts 转发 output.filename 和 performance.profile。

    示例

    在 rsbuild.config.ts 中将该插件注册在某个 DSL 插件旁边。 环境名(下面的 lynx)会成为 bundle 文件名中的 [platform] 占位符, 因此该配置的默认输出为 dist/main.lynx.bundle。

    rsbuild.config.ts
    import { defineConfig } from '@rsbuild/core'
    import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
    import { pluginLynx } from '@lynx-js/rsbuild-plugin'
    
    export default defineConfig({
      source: {
        entry: { main: './src/index.tsx' },
      },
      environments: {
        lynx: {},
      },
      plugins: [
        pluginLynx({
          performance: { profile: false },
        }),
        pluginReactLynx(),
      ],
    })

    然后使用 Rsbuild CLI:

    rsbuild dev
    rsbuild build

    备注

    要从 Rspeedy 迁移,请将 rspeedy dev / rspeedy build 替换为 rsbuild dev / rsbuild build,将 lynx.config.ts 重命名为 rsbuild.config.ts,并从 @rsbuild/core 导入 defineConfig。Rspeedy 用来转发给引擎的两个 选项,现在直接传给 pluginLynx:

    lynx.config.ts (Rspeedy)pluginLynx() (Rsbuild)
    output.filename as a stringoutput.filename.bundle
    output.filename.bundleoutput.filename.bundle
    output.filename.template (deprecated)output.filename.bundle
    performance.profileperformance.profile

    output、source、dev 和 server 中的其他所有内容都保持 Rsbuild 的形态,留在 rsbuild.config.ts 中。引擎会在 Rsbuild 默认值之上应用 Lynx 特有的默认值(bundle target、chunk loading、CSS 提取、source map),并且只在其他插件尚未设置某项配置时才会覆盖它。

    接口

    类型别名

    变量

    函数

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。