close
logologo
指南
配置
插件
API
社区
版本
更新日志
Rsbuild 0.x 文档
English
简体中文
指南
配置
插件
API
社区
更新日志
Rsbuild 0.x 文档
English
简体中文
logologo
Overview
root
mode
plugins
logLevel
environments

dev

dev.assetPrefix
dev.browserLogs
dev.cliShortcuts
dev.client
dev.hmr
dev.lazyCompilation
dev.liveReload
dev.progressBar
dev.setupMiddlewares
dev.watchFiles
dev.writeToDisk

resolve

resolve.aliasStrategy
resolve.alias
resolve.conditionNames
resolve.dedupe
resolve.extensions
resolve.mainFields

source

source.assetsInclude
source.decorators
source.define
source.entry
source.exclude
source.include
source.preEntry
source.transformImport
source.tsconfigPath

output

output.assetPrefix
output.charset
output.cleanDistPath
output.copy
output.cssModules
output.dataUriLimit
output.distPath
output.emitAssets
output.emitCss
output.externals
output.filenameHash
output.filename
output.injectStyles
output.inlineScripts
output.inlineStyles
output.legalComments
output.manifest
output.minify
output.module
output.overrideBrowserslist
output.polyfill
output.sourceMap
output.target

html

html.appIcon
html.crossorigin
html.favicon
html.inject
html.meta
html.mountId
html.outputStructure
html.scriptLoading
html.tags
html.templateParameters
html.template
html.title

server

server.base
server.compress
server.cors
server.headers
server.historyApiFallback
server.host
server.htmlFallback
server.https
server.middlewareMode
server.open
server.port
server.printUrls
server.proxy
server.publicDir
server.strictPort

security

security.nonce
security.sri

tools

tools.bundlerChain
tools.cssExtract
tools.cssLoader
tools.htmlPlugin
tools.lightningcssLoader
tools.postcss
tools.rspack
tools.styleLoader
tools.swc

performance

performance.buildCache
performance.bundleAnalyze
performance.chunkSplit
performance.dnsPrefetch
performance.preconnect
performance.prefetch
performance.preload
performance.printFileSize
performance.profile
performance.removeConsole
performance.removeMomentLocale

moduleFederation

moduleFederation.options
📝 在 GitHub 上编辑此页
上一页output.externals
下一页output.filename

#output.filenameHash

  • 类型: boolean | string
  • 默认值: true

在生产模式构建后,是否在产物的文件名中添加 hash 值。

#禁用 hash

默认情况下,构建后的产物名称会包含 hash 值:

dist/static/css/index.7879e19d.css
dist/static/js/index.18a568e5.js

你可以将 output.filenameHash 设置为 false 来禁用这个行为:

export default {
  output: {
    filenameHash: false,
  },
};

重新构建后,产物的名称变为:

dist/static/css/index.css
dist/static/js/index.js

#hash 格式

hash 的默认格式为 contenthash:8,即基于文件内容生成 8 位 hash。

你可以将 output.filenameHash 设置为 Rspack 支持的其他格式,并自定义长度。

export default {
  output: {
    filenameHash: 'fullhash:16',
  },
};

可选的 hash 格式为:

  • fullhash:整个编译过程的哈希值,如果任何一个文件发生变动,整个项目的所有输出文件的哈希值都会改变
  • chunkhash:chunk 的哈希值,如果 chunk 内容(及其包含的模块)发生改变,哈希值才会改变。
  • contenthash:文件内容的哈希值,只有当文件本身的内容发生变更时,哈希值才会改变。

#注意事项

  • output.filename 的优先级高于 output.filenameHash。
  • 默认情况下,当 target 不是 web 时,产物的文件名不会包含 hash,比如 Node.js 产物。
  • 默认情况下,开发模式构建产物的文件名不会包含 hash。