Skip to content

Commit 1e55af3

Browse files
authored
docs: clarify cssHash in dev (#370)
1 parent 56f2422 commit 1e55af3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

docs/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ These options are specific to the Svelte compiler and are generally shared acros
8383

8484
- **Type:** `CompileOptions` - See [svelte.compile](https://svelte.dev/docs#svelte_compile)
8585

86-
The options to be passed to the Svelte compiler. A few options are set by default, including `dev` and `css`. However, some options are non-configurable, like `filename`, `format`, `generate`, and `cssHash` (in dev).
86+
The options to be passed to the Svelte compiler. A few options are set by default, including `dev` and `css`. However, some options are non-configurable, like `filename`, `format`, `generate`, and `cssHash` ([in dev](./faq.md#why-cant-csshash-be-set-in-development-mode)).
8787

8888
### preprocess
8989

docs/faq.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ Bad:
7373
</style>
7474
```
7575

76+
### Why can't `cssHash` be set in development mode?
77+
78+
`cssHash` is fixed in development for CSS HMR in Svelte components, ensuring that the hash value is stable based on the file name so that styles are only updated when changed.
79+
80+
However, `cssHash` is respected in production builds as HMR is a dev-only feature.
81+
7682
### How do I add a Svelte preprocessor from a Vite plugin?
7783

7884
If you are building a Vite plugin that transforms CSS or JS, you can add a `api.sveltePreprocess: PreprocessorGroup` to your Vite plugin definition and it will be added to the list of Svelte preprocessors used at runtime.

0 commit comments

Comments
 (0)