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/build/dev/write-to-disk.md.
Lynx
  • 简体中文
  • dev.writeToDisk

    optional writeToDisk?: boolean | ((filename: string) => boolean)

    Lynx 默认值覆盖

    此项是 Rsbuild 配置,pluginLynx 覆盖了它的默认值。下方默认值指应用插件后的值。请在 rsbuild.config.ts 顶层配置,显式设置的值优先。

    完整行为见 Rsbuild 配置参考。

    用于控制是否将开发环境的构建产物写入磁盘。

    默认值

    true

    备注

    该选项会透传给 `webpack-dev-middleware`。

    设置 writeToDisk: true 不会改变 webpack-dev-middleware 的行为,通过浏览器访问的 bundle 文件仍然由内存提供。

    该选项也接受 Function 类型的值,可用于过滤需要写入磁盘的文件。

    该函数的逻辑与 Array#filter 相同:返回 false 时不写入该文件,返回 true 时将该文件写入磁盘。

    示例

    // lynx.config.ts
    import { defineConfig } from '@lynx-js/rspeedy'
    export default defineConfig({
      dev: {
        writeToDisk: (filePath) => /superman\.css$/.test(filePath),
      },
    })
    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。