How to tell rsbuild when to hash, and when not to hash? #7587
Replies: 3 comments 9 replies
-
|
Under notes at https://github.com/web-infra-dev/rsbuild/blob/main/website/docs/en/config/output/filename-hash.mdx#notes you mention Can I somehow override this behaviour and configure this myself? |
Beta Was this translation helpful? Give feedback.
-
|
You only need to customize JS and CSS filenames: const NON_LOCAL_FILENAME = {
js: `[name].${FILE_NAME_HASH}.js`,
css: `[name].${FILE_NAME_HASH}.css`,
};Other assets already respect |
Beta Was this translation helpful? Give feedback.
-
|
I see. Thanks for explaining.
Ok, let's not export internals. Agree.
I see. I wonder, is there a callback function to adjust ... you will want to fine-tune what assets to hash, what assets to cache and which one not, while seeing stack traces for some, while sticking to defaults whatever is not defined. For example, you have this for local development using HMR: // Development mode
const devDefaultFilename = {
html: '[name].html',
js: '[name].js',
css: '[name].css',
svg: '[name].[contenthash:10].svg',
...
};What if I set up a new Test server, also running on NODE_ENV = DEV. This for QA tests, while I still want to any full error stack trace: // Test mode
const testDefaultFilename = {
html: '[name].html', // <-- Okay, that one is an exception, do not hash index.html
js: '[name].[contenthash:10].js',
css: '[name].[contenthash:10].css',
svg: '[name].[contenthash:10].svg',
...
};This is not possible right now, unfortunately. Related code: I understand, this is a tricky question:
Fair enough. This makes sense for most simple set-ups, but when you run multiple servers and environments, it would be good to finetune this further. Mode (NODE_ENV) !== Servers / Environment |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello - I'm running multiple environments: Local, Delivery, Test and Production.
On Test and Production, NODE_ENV is set to PROD. But For Local and Delivery, it's DEV.
But I want rsbuild to amend content hashes to all assets for every environment except LOCAL. How to configure this best?
For now, I wrote this code, but I am not happy about it, and wonder if you have better ideas or suggestions for this scenario?
Beta Was this translation helpful? Give feedback.
All reactions