feat: add deterministic local CSS naming option - #4391
Conversation
bfb4a1d to
a250fe6
Compare
This feature introduces a new option `DeterministicLocalCSSNaming` that, when true, ensures that local CSS class names are generated in a deterministic manner. This is particularly useful for caching and consistent builds across different environments. When `MinifyIdentifiers` is enabled, the local name is generated as the original CSS class name, and a hash of the absolute source file path, separated by an underscore (eg. `<original-class-name>_<hash-of-absolute-path>`). When `MinifyIdentifiers` is disabled, the local name is appended with a CSS safe version of the relative source file path (eg. `<original-class-name>_<hash-of-absolute-path>_<relative-source-file-path>`) to aid in development.
a250fe6 to
9886767
Compare
|
Hi thank you! using a hash would fix my problem from #3484 indeed if the hash contains the package name of the npm package which it does due to the absolute path. Now i have a question: As this change attempts to make bundles deterministic that two setups produce the same minified code, isnt it counterproductive to have the full absolute path being used for building the hash? Especially when people do not use a standardised docker container where their source code resides on the exact same path but work locally? Can we instead use some kind of relative path + if applicable the npm package name? |
|
The absolute path is used, because sometimes assets are located outside of the project. In which case, relative paths will not work. |
|
paths could still be calculated via relative traversal |
|
Yes, but then you may as well use absolute paths, and they are more readable. |
This feature introduces a new option
DeterministicLocalCSSNamingthat, when true, ensures that local CSS class names are generated in a deterministic manner. This is particularly useful for caching and consistent builds across different environments.When
MinifyIdentifiersis enabled, the local name is generated as the original CSS class name, and a hash of the absolute source file path, separated by an underscore (eg.<original-class-name>_<hash-of-absolute-path>).When
MinifyIdentifiersis disabled, the local name is appended with a CSS safe version of the relative source file path (eg.<original-class-name>_<hash-of-absolute-path>_<relative-source-file-path>) to aid in development.May address #3484?