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/rspeedy/rspeedy.config.mode.md.
Rspeedy logo
Rspeedy
  • English
  • Home > @lynx-js/rspeedy > Config > mode

    Config.mode property

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

    Signature:

    mode?: 'development' | 'production' | 'none' | undefined;

    Default Value

    Depends on process.env.NODE_ENV: 'production' when NODE_ENV is 'production', 'development' when NODE_ENV is 'development', and 'none' otherwise. When using Rspeedy's CLI, rspeedy dev and rspeedy preview default to 'development', while rspeedy build defaults to 'production'.

    Example 1

    If the value of mode is 'development':

    • Enable HMR and register the HotModuleReplacementPlugin.

    • Generate JavaScript and CSS source maps. In Lynx environments, all .map assets are removed before emit. See 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.

    Example 2

    If the value of mode is 'production':

    • Enable JavaScript code minification and register the SwcJsMinimizerRspackPlugin.

    • Generated JavaScript and CSS filenames will have hash suffixes, see Output.filenameHash.

    • Generated CSS Modules classnames will be shorter, see CssModules.localIdentName.

    • Generate JavaScript and CSS source maps. In Lynx environments, all .map assets are removed before emit. See 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.

    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.