File tree Expand file tree Collapse file tree 4 files changed +18
-8
lines changed
Expand file tree Collapse file tree 4 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 11# Svelte preprocess CSS Modules, changelog
22
3+ ## 1.3.1 (Nov 22, 2020)
4+ Add support for old version of nodes (node 8 & node 10 tested)
5+
36## 1.3.0 (Nov 22, 2020)
4- - Feature: CSS Modules from imports
5- - Fix: * global selector* Regex is now working with an attached bracket to the selector (missing space was throwing an error) ` .myclass{ } `
6- - Dev: use of typescript, set up eslint and prettier
7+
8+ ### Feature
9+ Apply CSS Modules from imported stylesheets
10+
11+ ### Fixes
12+ * global selector* Regex is now working with an attached bracket to the selector (missing space was throwing an error) ` .myclass{ } `
13+
14+ ### Plugin Development
15+ Set up typescript, eslint and prettier
716
817## 1.2.1 (Oct 31, 2020)
918- Fix class chaining and pseudo selector [ pull request #8 ] ( https://github.com/micantoine/svelte-preprocess-cssmodules/pull/8 )
Original file line number Diff line number Diff line change 11{
22 "name" : " svelte-preprocess-cssmodules" ,
3- "version" : " 1.3.0 " ,
3+ "version" : " 1.3.1 " ,
44 "description" : " Svelte preprocessor to generate CSS Modules classname on Svelte components" ,
55 "keywords" : [
66 " svelte" ,
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ export const PATTERN_MODULE = /\$(style)?\.(:?[\w\d-]*)/gm;
22export const PATTERN_PATH_UNALLOWED = / [ < > : " / \\ | ? * ] / g;
33export const PATTERN_STYLE = / < s t y l e ( \s [ ^ ] * ?) ? > ( [ ^ ] * ?) < \/ s t y l e > / gi;
44export const PATTERN_IMPORT = / (?< ! \/ \/ \s * ) i m p o r t \s * (?: ( .+ ) \s + f r o m \s + ) ? [ ' | " ] ( .+ ?( s ? c s s ) ) [ ' | " ] ; ? / gm;
5- export const PATTERN_CLASS_SELECTOR = / \. (?< className > .+ ?(? = \W ) + ) (? ! [ - _ ] ) / g;
5+ export const PATTERN_CLASS_SELECTOR = / \. ( .+ ?(? = \W ) + ) (? ! [ - _ ] ) / g;
66
77export const PATTERN_CLASS_DIRECTIVE = ( className : string ) : RegExp =>
88 new RegExp ( `<.+\\s*class:(${ className } )\\b` , 'gm' ) ;
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ const parseMarkup = async (
9696
9797 const classlist = new Map ( ) ;
9898 Array . from ( matchAll ( fileContent , PATTERN_CLASS_SELECTOR ) ) . forEach ( ( matchItem ) => {
99+ const className = matchItem [ 1 ] ;
99100 // set array from exported className
100101 const destructuredImportRegex = / \{ ( [ \w , \s ] + ) \} / gm;
101102 const isDestructuredImport : boolean = varName . search ( destructuredImportRegex ) !== - 1 ;
@@ -109,7 +110,7 @@ const parseMarkup = async (
109110 }
110111 }
111112
112- const camelCaseClassName = camelCase ( matchItem . groups . className ) ;
113+ const camelCaseClassName = camelCase ( className ) ;
113114
114115 if (
115116 ! classlist . has ( camelCaseClassName ) &&
@@ -120,11 +121,11 @@ const parseMarkup = async (
120121 filename ,
121122 content ,
122123 fileContent ,
123- matchItem . groups . className ,
124+ className ,
124125 pluginOptions
125126 ) ;
126127 classlist . set ( camelCaseClassName , interpolatedName ) ;
127- cssModuleList [ matchItem . groups . className ] = interpolatedName ;
128+ cssModuleList [ className ] = interpolatedName ;
128129
129130 // consider use with class directive
130131 const directiveClass = isDestructuredImport
You can’t perform that action at this time.
0 commit comments