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/rspeedy/interfaces/Config.md.
Lynx
  • 简体中文
  • 接口: Config

    Config 是 rspeedy 使用的配置。

    属性

    dev?

    optional dev?: Dev

    Dev 选项用于控制与开发相关的行为,包括 HMR、DevServer 等。

    默认值

    undefined

    environments?

    optional environments?: Record<string, EnvironmentConfig>

    Lynx Default Changed

    Config.environments 选项用于设置输出的 environment。

    默认值

    未设置该选项时,Rspeedy 会向 Rsbuild 传入 { lynx: {} }。

    备注

    如果你没有使用 Lynx for Web,通常不需要此选项。

    示例

    • 为 Lynx 和 Web 使用不同的入口。
    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      environments: {
        lynx: {},
        web: {
          source: { entry: { web: './src/index.web.jsx' } },
        },
      },
      source: {
        entry: './src/index.jsx',
      },
    })
    • 仅构建 Web 产物。
    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      environments: {
        web: {
          source: { entry: { web: './src/index.web.jsx' } },
        },
      },
    })

    mode?

    optional mode?: "production" | "development" | "none"

    指定 Rsbuild 和 Rspack 的构建模式,不同模式有不同的默认行为和优化。

    默认值

    取决于 process.env.NODE_ENV:

    • NODE_ENV 为 'production' 时为 'production'
    • NODE_ENV 为 'development' 时为 'development'
    • 其他情况为 'none'

    使用 Rspeedy CLI 时,rspeedy dev 和 rspeedy preview 默认为 'development',rspeedy build 默认为 'production'。

    示例

    If the value of `mode` is `'development'`:
    
    - Enable HMR and register the {@link https://rspack.rs/plugins/webpack/hot-module-replacement-plugin | HotModuleReplacementPlugin}.
    
    - Generate JavaScript and CSS source maps. In Lynx environments, all `.map` assets are removed before emit. See {@link Output.sourceMap} for details.
    
    - The `process.env.NODE_ENV` in the source code will be replaced with `'development'`.
    
    - The `import.meta.env.MODE` in the source code will be replaced with `'development'`.
    
    - The `import.meta.env.DEV` in the source code will be replaced with `true`.
    
    - The `import.meta.env.PROD` in the source code will be replaced with `false`.
    If the value of `mode` is `'production'`:
    
    - Enable JavaScript code minification and register the {@link https://rspack.rs/plugins/rspack/swc-js-minimizer-rspack-plugin | SwcJsMinimizerRspackPlugin}.
    
    - Generated JavaScript and CSS filenames will have hash suffixes, see {@link Output.filenameHash}.
    
    - Generated CSS Modules classnames will be shorter, see {@link CssModules.localIdentName}.
    
    - Generate JavaScript and CSS source maps. In Lynx environments, all `.map` assets are removed before emit. See {@link Output.sourceMap}.
    
    - The `process.env.NODE_ENV` in the source code will be replaced with `'production'`.
    
    - The `import.meta.env.MODE` in the source code will be replaced with `'production'`.
    
    - The `import.meta.env.DEV` in the source code will be replaced with `false`.
    
    - The `import.meta.env.PROD` in the source code will be replaced with `true`.

    output?

    optional output?: Output

    Output 选项用于设置 bundle 和静态资源的输出方式与输出位置。

    默认值

    undefined

    performance?

    optional performance?: Performance

    Performance 选项用于优化构建时和运行时的性能。

    默认值

    undefined

    plugins?

    optional plugins?: RsbuildPlugins

    plugins 选项用于以多种方式自定义构建流程。

    默认值

    undefined

    备注

    Rspeedy 使用 Rsbuild 的插件 API。开发插件请参阅相应文档。


    resolve?

    optional resolve?: Resolve

    Resolve 选项用于控制 Rspack 的模块解析行为。

    默认值

    undefined

    server?

    optional server?: Server

    Server 选项用于改变 dev-server 的行为。

    默认值

    undefined

    source?

    optional source?: Source

    Source 选项用于修改源文件相关的行为。

    默认值

    undefined

    splitChunks?

    optional splitChunks?: false | SplitChunksConfig

    配置 chunk 拆分。

    默认值

    Rspeedy 将其默认设为 false;如果配置了该项,Rsbuild 会通过其顶层的 splitChunks 选项来处理。

    备注

    详见 Rsbuild - splitChunks。


    tools?

    optional tools?: Tools

    Tools 选项用于修改各类构建工具的行为。

    默认值

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