@@ -161,6 +161,89 @@ test('CSS Modules', async () => {
161161  ) 
162162} ) 
163163
164+ test ( 'CSS Modules namedExport' ,  async  ( )  =>  { 
165+   const  testWithIdent  =  async  ( 
166+     localIdentName : string  |  undefined , 
167+     regexToMatch : RegExp 
168+   )  =>  { 
169+     const  baseLoaders  =  [ 
170+       { 
171+         loader : 'style-loader' , 
172+         options : { 
173+           modules : { 
174+             namedExport : true , 
175+           } , 
176+         } , 
177+       } , 
178+       { 
179+         loader : 'css-loader' , 
180+         options : { 
181+           modules : { 
182+             localIdentName, 
183+             namedExport : true , 
184+           } , 
185+         } , 
186+       } , 
187+     ] 
188+ 
189+     const  {  window,  instance }  =  await  mockBundleAndRun ( { 
190+       entry : 'css-modules.vue' , 
191+       modify : ( config : any )  =>  { 
192+         config ! . module ! . rules  =  [ 
193+           { 
194+             test : / \. v u e $ / , 
195+             loader : 'vue-loader' , 
196+           } , 
197+           { 
198+             test : / \. c s s $ / , 
199+             use : baseLoaders , 
200+           } , 
201+           { 
202+             test : / \. s t y l u s $ / , 
203+             use : [ ...baseLoaders ,  'stylus-loader' ] , 
204+           } , 
205+         ] 
206+       } , 
207+     } ) 
208+ 
209+     // get local class name 
210+     const  className  =  instance . $style . red 
211+     expect ( className ) . toMatch ( regexToMatch ) 
212+ 
213+     // class name in style 
214+     let  style  =  [ ] . slice 
215+       . call ( window . document . querySelectorAll ( 'style' ) ) 
216+       . map ( ( style : any )  =>  { 
217+         return  style ! . textContent 
218+       } ) 
219+       . join ( '\n' ) 
220+     style  =  normalizeNewline ( style ) 
221+     expect ( style ) . toContain ( '.'  +  className  +  ' {\n  color: red;\n}' ) 
222+ 
223+     // animation name 
224+     const  match  =  style . match ( / @ k e y f r a m e s \s + ( \S + ) \s + { / ) 
225+     expect ( match ) . toHaveLength ( 2 ) 
226+     const  animationName  =  match [ 1 ] 
227+     expect ( animationName ) . not . toBe ( 'fade' ) 
228+     expect ( style ) . toContain ( 'animation: '  +  animationName  +  ' 1s;' ) 
229+ 
230+     // default module + pre-processor + scoped 
231+     const  anotherClassName  =  instance . $style . red 
232+     expect ( anotherClassName ) . toMatch ( regexToMatch ) 
233+     const  id  =  'data-v-'  +  genId ( 'css-modules.vue' ) 
234+     expect ( style ) . toContain ( '.'  +  anotherClassName  +  '['  +  id  +  ']' ) 
235+   } 
236+ 
237+   // default ident 
238+   await  testWithIdent ( undefined ,  / ^ \w { 21 , } / ) 
239+ 
240+   // custom ident 
241+   await  testWithIdent ( 
242+     '[path][name]---[local]---[hash:base64:5]' , 
243+     / c s s - m o d u l e s - - - r e d - - - \w { 5 } / 
244+   ) 
245+ } ) 
246+ 
164247test ( 'CSS Modules Extend' ,  async  ( )  =>  { 
165248  const  baseLoaders  =  [ 
166249    'style-loader' , 
0 commit comments