Skip to content

Commit 08e9f18

Browse files
committed
feat: hashing css names by filename
picks either filename or component name or css texts
1 parent bde51ed commit 08e9f18

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/svelte/src/compiler/validate-options.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ const component_options = {
7070
return input;
7171
}),
7272

73-
cssHash: fun(({ css, hash }) => {
74-
return `svelte-${hash(css)}`;
73+
cssHash: fun(({ css, filename, name, hash }) => {
74+
//either use extracted filename or component name
75+
filename = filename ? filename.replace(/^.*[\\/]/, '') : name;
76+
return `svelte-${hash(filename ?? css )}`;
7577
}),
7678

7779
// TODO this is a sourcemap option, would be good to put under a sourcemap namespace

0 commit comments

Comments
 (0)