This repository was archived by the owner on Sep 25, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +61
-0
lines changed
Expand file tree Collapse file tree 4 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -4,17 +4,20 @@ import { cssModules } from '../src';
44type Params = {
55 source : string ;
66 preprocessOptions : Parameters < typeof preprocess > [ 2 ] ;
7+ cssmodulesOptions ?: Parameters < typeof cssModules > [ 0 ] ;
78} ;
89
910export async function compiler ( {
1011 source,
1112 preprocessOptions,
13+ cssmodulesOptions,
1214} : Params ) {
1315 const { code } = await preprocess (
1416 source ,
1517 [ cssModules ( {
1618 moduleNameingPattern : '[local]_[name]-css-module-test' ,
1719 includeOriginalPath : false ,
20+ ...cssmodulesOptions ,
1821 } ) ] ,
1922 preprocessOptions ,
2023 ) ;
Original file line number Diff line number Diff line change 1+ <script >
2+ import s from ' ../assets/style.module.css' ;
3+ </script >
4+
5+ <div class ={s [' success-message' ]}>
6+ hello
7+ </div >
8+
Original file line number Diff line number Diff line change 1+ <script >
2+ const s = {
3+ error: " error_style-module-css-module-test" ,
4+ " success-message" : " success-message_style-module-css-module-test"
5+ };
6+ </script >
7+
8+ <div class ={s [' success-message' ]}>
9+ hello
10+ </div >
11+
12+
13+ <style >
14+
15+
16+ section {
17+ padding : 10px ;
18+ }
19+
20+ .error_style-module-css-module-test {
21+ color : red ;
22+ }
23+
24+ .success-message_style-module-css-module-test {
25+ color : green ;
26+ }
27+
28+ </style >
Original file line number Diff line number Diff line change 1+ import fs from 'node:fs/promises' ;
2+ import path from 'node:path' ;
3+ import { expect , it } from 'vitest' ;
4+ import { compiler } from '../compiler' ;
5+
6+ export function resolve ( file : string ) {
7+ return path . resolve ( __dirname , file ) ;
8+ }
9+
10+ it ( 'non-camelcase' , { retry : 5 } , async ( ) => {
11+ const filename = resolve ( 'Input.svelte' ) ;
12+
13+ const source = await fs . readFile ( filename , 'utf-8' ) ;
14+
15+ const code = await compiler ( {
16+ source,
17+ preprocessOptions : { filename } ,
18+ cssmodulesOptions : { convertToCamelCase : false } ,
19+ } ) ;
20+
21+ await expect ( code ) . toMatchFileSnapshot ( './Output.svelte' ) ;
22+ } ) ;
You can’t perform that action at this time.
0 commit comments