File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,10 @@ const pluginOptions = {
8
8
9
9
const regex = {
10
10
module : / \$ s t y l e \. ( : ? [ \w \d - ] * ) / gm,
11
- style : / < s t y l e ( \s [ ^ ] * ?) ? > ( [ ^ ] * ?) < \/ s t y l e > / gi
11
+ style : / < s t y l e ( \s [ ^ ] * ?) ? > ( [ ^ ] * ?) < \/ s t y l e > / gi,
12
+ class : ( className ) => {
13
+ return new RegExp ( `\\.(${ className } )\\b(?![-_])` , 'gm' )
14
+ }
12
15
} ;
13
16
14
17
let moduleClasses = { } ;
@@ -58,9 +61,7 @@ const markup = async ({ content, filename }) => {
58
61
return { code : content . replace ( regex . module , ( match , className ) => {
59
62
let replacement = '' ;
60
63
if ( styles . length ) {
61
- const classRegex = new RegExp ( `\\.(${ className } )\\b(?![-_])` , 'gm' ) ;
62
-
63
- if ( classRegex . test ( styles [ 0 ] ) ) {
64
+ if ( regex . class ( className ) . test ( styles [ 0 ] ) ) {
64
65
const interpolatedName = generateName (
65
66
filename ,
66
67
styles [ 0 ] ,
@@ -83,9 +84,8 @@ const style = async ({ content, filename }) => {
83
84
}
84
85
85
86
for ( const className in classes ) {
86
- const classRegex = new RegExp ( `\\.(${ className } )\\b(?![-_])` , 'gm' ) ;
87
87
code = code . replace (
88
- classRegex ,
88
+ regex . class ( className ) ,
89
89
( ) => `:global(.${ classes [ className ] } )`
90
90
) ;
91
91
}
You can’t perform that action at this time.
0 commit comments