Skip to content

Commit 4c5ad22

Browse files
committed
Update Readme
1 parent 5661f4d commit 4c5ad22

File tree

4 files changed

+68
-87
lines changed

4 files changed

+68
-87
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Svelte preprocess CSS Modules, changelog
22

3+
## 2.1.0-rc.1 (Oct 6, 2021)
4+
- Add ESM distribution
5+
36
## 2.0.2 (May 26, 2021)
47
- Fix Readme
58

README.md

Lines changed: 62 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ npm install --save-dev svelte-preprocess-cssmodules
1818
- [Configuration](#configuration)
1919
- [Rollup](#rollup)
2020
- [Webpack](#webpack)
21+
- [SvelteKit](#sveltekit)
2122
- [Svelte Preprocess](#svelte-preprocess)
2223
- [Options](#options)
2324
- [Migrating from v1](#migrating-from-v1)
@@ -440,6 +441,26 @@ module.exports = {
440441
}
441442
```
442443

444+
### SvelteKit
445+
446+
As the module distribution is targetting `esnext`, `Node.js 14` or above is required
447+
in order to work.
448+
449+
```js
450+
// svelte.config.js
451+
452+
import cssModules from 'svelte-preprocess-cssmodules';
453+
454+
const config = {
455+
...
456+
preprocess: [
457+
cssModules(),
458+
]
459+
};
460+
461+
export default config;
462+
```
463+
443464
### Svelte Preprocess
444465

445466
Chaining several preprocessors may lead to errors if the svelte parser and walker is being manipulated multiple time. This issue is due to the way svelte runs its preprocessor in two phases. [Read more here](https://github.com/firefish5000/svelte-as-markup-preprocessor#motivation)
@@ -681,54 +702,36 @@ export default {
681702
<style module>
682703
.modal {
683704
position: fixed;
684-
top: 50%;
685-
left: 50%;
686-
z-index: 10;
687-
width: 400px;
688-
height: 80%;
689-
background-color: #fff;
690-
transform: translateX(-50%) translateY(-50%);
691-
}
692-
section {
693-
flex: 0 1 auto;
694-
flex-direction: column;
695-
display: flex;
696-
height: 100%;
705+
...
697706
}
698707
header {
699-
padding: 1rem;
700-
border-bottom: 1px solid #d9d9d9;
708+
...
701709
}
702710
.body {
703-
padding: 1rem;
704711
flex: 1 0 0;
712+
...
705713
}
706714
footer {
707-
padding: 1rem;
708-
border-top: 1px solid #d9d9d9;
715+
...
709716
}
710717
button {
711-
background: #fff;
712-
border: 1px solid #ccc;
713-
border-radius: 5px;
718+
...
714719
}
715720
.cancel {
716721
background-color: #f2f2f2;
717722
}
718723
</style>
719724

720-
<div class="modal">
721-
<section>
722-
<header>My Modal Title</header>
723-
<div class="body">
724-
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit.</p>
725-
</div>
726-
<footer>
727-
<button>Ok</button>
728-
<button class="cancel">Cancel</button>
729-
</footer>
730-
</section>
731-
</div>
725+
<section class="modal">
726+
<header>My Modal Title</header>
727+
<div class="body">
728+
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit.</p>
729+
</div>
730+
<footer>
731+
<button>Ok</button>
732+
<button class="cancel">Cancel</button>
733+
</footer>
734+
</section>
732735
```
733736

734737
***OR** Svelte Component using `import`*
@@ -737,13 +740,7 @@ export default {
737740
/** style.module.css */
738741
.modal {
739742
position: fixed;
740-
top: 50%;
741-
left: 50%;
742-
z-index: 10;
743-
width: 400px;
744-
height: 80%;
745-
background-color: #fff;
746-
transform: translateX(-50%) translateY(-50%);
743+
...
747744
}
748745

749746
[...]
@@ -753,18 +750,16 @@ export default {
753750
import style from './style.module.css';
754751
</script>
755752

756-
<div class={style.modal}>
757-
<section>
758-
<header>My Modal Title</header>
759-
<div class={style.body}>
760-
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit.</p>
761-
</div>
762-
<footer>
763-
<button>Ok</button>
764-
<button class={style.cancel}>Cancel</button>
765-
</footer>
766-
</section>
767-
</div>
753+
<section class={style.modal}>
754+
<header>My Modal Title</header>
755+
<div class={style.body}>
756+
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit.</p>
757+
</div>
758+
<footer>
759+
<button>Ok</button>
760+
<button class={style.cancel}>Cancel</button>
761+
</footer>
762+
</section>
768763
```
769764

770765
*Final html code generated by svelte*
@@ -773,54 +768,36 @@ export default {
773768
<style>
774769
._329TyLUs9c {
775770
position: fixed;
776-
top: 50%;
777-
left: 50%;
778-
z-index: 10;
779-
width: 400px;
780-
height: 80%;
781-
background-color: #fff;
782-
transform: translateX(-50%) translateY(-50%);
783-
}
784-
section {
785-
flex: 0 1 auto;
786-
flex-direction: column;
787-
display: flex;
788-
height: 100%;
771+
...
789772
}
790773
header {
791-
padding: 1rem;
792-
border-bottom: 1px solid #d9d9d9;
774+
...
793775
}
794776
._1HPUBXtzNG {
795-
padding: 1rem;
796777
flex: 1 0 0;
778+
...
797779
}
798780
footer {
799-
padding: 1rem;
800-
border-top: 1px solid #d9d9d9;
781+
...
801782
}
802783
button {
803-
background: #fff;
804-
border: 1px solid #ccc;
805-
border-radius: 5px;
784+
...
806785
}
807786
._1xhJxRwWs7 {
808787
background-color: #f2f2f2;
809788
}
810789
</style>
811790

812-
<div class="_329TyLUs9c">
813-
<section>
814-
<header>My Modal Title</header>
815-
<div class="_1HPUBXtzNG">
816-
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit.</p>
817-
</div>
818-
<footer>
819-
<button>Ok</button>
820-
<button class="_1xhJxRwWs7">Cancel</button>
821-
</footer>
822-
</section>
823-
</div>
791+
<section class="_329TyLUs9c">
792+
<header>My Modal Title</header>
793+
<div class="_1HPUBXtzNG">
794+
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit.</p>
795+
</div>
796+
<footer>
797+
<button>Ok</button>
798+
<button class="_1xhJxRwWs7">Cancel</button>
799+
</footer>
800+
</section>
824801
```
825802

826803
## Why CSS Modules on Svelte

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelte-preprocess-cssmodules",
3-
"version": "2.0.2",
3+
"version": "2.1.0-rc.1",
44
"description": "Svelte preprocessor to generate CSS Modules classname on Svelte components",
55
"keywords": [
66
"svelte",

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
],
2727
"exclude": [
2828
"node_modules",
29-
"dist"
29+
"dist",
30+
"tasks"
3031
]
3132
}

0 commit comments

Comments
 (0)