For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/packages/rspeedy/interfaces/Config.md.
Lynx
  • English
  • Interface: Config

    The Config is the configuration that rspeedy uses.

    Properties

    dev?

    optional dev?: Dev

    The Dev option is used to control the behavior related with development. Including: HMR, DevServer, etc.

    Default Value

    undefined

    environments?

    optional environments?: Record<string, EnvironmentConfig>

    Lynx Default Changed

    The Config.environments option is used to set the output environment.

    Default Value

    When this option is unset, Rspeedy passes { lynx: {} } to Rsbuild.

    Remarks

    Normally you don't need this if you are not using Lynx for Web.

    Examples

    • Using different entries for Lynx and 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',
      },
    })
    • Building Web-only outputs.
    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      environments: {
        web: {
          source: { entry: { web: './src/index.web.jsx' } },
        },
      },
    })

    mode?

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

    Specify the build mode for Rsbuild and Rspack, as each mode has different default behavior and optimizations.

    Default Value

    Depends on process.env.NODE_ENV:

    • 'production' when NODE_ENV is 'production'
    • 'development' when NODE_ENV is 'development'
    • 'none' otherwise

    With Rspeedy's CLI, rspeedy dev and rspeedy preview default to 'development', and rspeedy build defaults to 'production'.

    Examples

    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

    The Output option is used to set how and where should the bundles and assets output.

    Default Value

    undefined

    performance?

    optional performance?: Performance

    The Performance option is used to optimize the build-time and runtime performance.

    Default Value

    undefined

    plugins?

    optional plugins?: RsbuildPlugins

    The plugins option is used to customize the build process in a variety of ways.

    Default Value

    undefined

    Remarks

    Rspeedy uses the plugin APIs from Rsbuild. See the corresponding document for developing a plugin.


    resolve?

    optional resolve?: Resolve

    The Resolve option is used to control the resolution behavior of Rspack.

    Default Value

    undefined

    server?

    optional server?: Server

    The Server option changes the behavior of dev-server.

    Default Value

    undefined

    source?

    optional source?: Source

    The Source option changes the behavior of source files.

    Default Value

    undefined

    splitChunks?

    optional splitChunks?: false | SplitChunksConfig

    Configure chunk splitting.

    Default Value

    Rspeedy defaults this to false; if configured, Rsbuild handles it with its top-level splitChunks option.

    Remarks

    See Rsbuild - splitChunks for details.


    tools?

    optional tools?: Tools

    The Tools options changes the behavior of various building tools.

    Default Value

    undefined
    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.