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/rspeedy/rspeedy.filename.js.md.
Rspeedy logo
Rspeedy
  • 简体中文
  • Home > @lynx-js/rspeedy > Filename > js

    Filename.js property

    The name of the JavaScript files.

    Signature:

    js?: Rspack.Filename | undefined;

    Default Value

    '[name].js' in development, '[name].[contenthash:8].js' in production web builds, and '[name].js' in production node builds

    Example

    • Using a function to dynamically set the filename based on the file information:
    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      output: {
        filename: {
          js: (pathData, assetInfo) => {
            console.log(pathData); // You can check the contents of pathData here
    
            if (pathData.chunk?.name === 'index') {
              return isProd ? '[name].[contenthash:8].js' : '[name].js';
            }
            return '/some-path/[name].js';
          },
        },
      },
    })
    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。