You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Customize the creation of the classname instead of relying on the built-in function.
552
+
553
+
```ts
554
+
function getLocalIdent(
555
+
context: {
556
+
context:string, // the context path
557
+
resourcePath:string, // path + filename
558
+
},
559
+
localIdentName: {
560
+
template:string, // the template rule
561
+
interpolatedName:string, // the built-in generated classname
562
+
},
563
+
className:string, // the classname string
564
+
content: {
565
+
markup:string, // the markup content
566
+
style:string, // the style content
567
+
}
568
+
):string {
569
+
return`your_generated_classname`;
570
+
}
571
+
```
549
572
550
573
**`hashSeeder`**
551
574
552
-
Set the resource content of `[hash]`and`[contenthash]`.
575
+
Set the source to create the hash from (when using `[hash]`/`[contenthash]`).
553
576
554
577
The list of available keys are:
555
578
@@ -588,30 +611,6 @@ preprocess: [
588
611
</style>
589
612
```
590
613
591
-
**`getLocalIdent`**
592
-
593
-
Customize the creation of the classname instead of relying on the built-in function.
594
-
595
-
```ts
596
-
function getLocalIdent(
597
-
context: {
598
-
context:string, // the context path
599
-
resourcePath:string, // path + filename
600
-
},
601
-
localIdentName: {
602
-
template:string, // the template rule
603
-
interpolatedName:string, // the built-in generated classname
604
-
},
605
-
className:string, // the classname string
606
-
content: {
607
-
markup:string, // the markup content
608
-
style:string, // the style content
609
-
}
610
-
):string {
611
-
return`your_generated_classname`;
612
-
}
613
-
```
614
-
615
614
**`includeAttributes`**
616
615
617
616
Add other attributes than `class` to be parsed by the preprocesser
@@ -700,6 +699,7 @@ Inspired by [webpack interpolateName](https://github.com/webpack/loader-utils#in
700
699
701
700
Globally replace the default svelte scoping by the cssModules scoping. As a result, the `module` attribute to `<style>` becomes unnecessary.
702
701
702
+
703
703
```js
704
704
// Preprocess config
705
705
...
@@ -725,6 +725,24 @@ preprocess: [
725
725
.title-erYt1 { color: blue }
726
726
</style>
727
727
```
728
+
729
+
**Beware**
730
+
The enabled option will applied cssModules scoping to all imported Svelte files, even the ones coming from `node_modules`. When using a third party library, make sure the compiled version is being imported. In the case of a raw svelte file, its styling may be broken.
731
+
732
+
To prevent any scoping conflict, it is recommended to associate the option `useAsDefaultScoping` with `includePaths`.
733
+
734
+
```js
735
+
// Preprocess config
736
+
...
737
+
preprocess: [
738
+
cssModules([
739
+
useAsDefaultScoping:true,
740
+
includePaths: ['./src'],
741
+
]),
742
+
],
743
+
...
744
+
```
745
+
728
746
## Migrating from v1
729
747
If you want to migrate an existing project to `v2` keeping the approach of the 1st version, follow the steps below:
0 commit comments