File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ <style module="style">
2
+ .red {
3
+ color : red ;
4
+ }
5
+ @keyframes fade {
6
+ from { opacity : 1 ; } to { opacity : 0 ; }
7
+ }
8
+ .animate {
9
+ animation : fade 1s ;
10
+ }
11
+ </style >
12
+
13
+ <style scoped lang="stylus" module>
14
+ .red
15
+ color : red
16
+ </style >
17
+
18
+ <script >
19
+ module .exports = {}
20
+ </script >
Original file line number Diff line number Diff line change @@ -377,4 +377,37 @@ describe('vue-loader', function () {
377
377
done ( )
378
378
} )
379
379
} )
380
+
381
+ it ( 'css-modules' , function ( done ) {
382
+ test ( {
383
+ entry : './test/fixtures/css-modules.vue'
384
+ } , function ( window ) {
385
+ var module = window . vueModule
386
+
387
+ // get local class name
388
+ var className = module . computed . style ( ) . red
389
+ expect ( className ) . to . match ( / ^ _ / )
390
+
391
+ // class name in style
392
+ var style = [ ] . slice . call ( window . document . querySelectorAll ( 'style' ) ) . map ( function ( style ) {
393
+ return style . textContent
394
+ } ) . join ( '\n' )
395
+ expect ( style ) . to . contain ( '.' + className + ' {\n color: red;\n}' )
396
+
397
+ // animation name
398
+ var match = style . match ( / @ k e y f r a m e s \s + ( \S + ) \s + { / )
399
+ expect ( match ) . to . have . length ( 2 )
400
+ var animationName = match [ 1 ]
401
+ expect ( animationName ) . to . not . equal ( 'fade' )
402
+ expect ( style ) . to . contain ( 'animation: ' + animationName + ' 1s;' )
403
+
404
+ // default module + pre-processor + scoped
405
+ var anotherClassName = module . computed . $style ( ) . red
406
+ expect ( anotherClassName ) . to . match ( / ^ _ / ) . and . not . equal ( className )
407
+ var id = '_v-' + hash ( require . resolve ( './fixtures/css-modules.vue' ) )
408
+ expect ( style ) . to . contain ( '.' + anotherClassName + '[' + id + ']' )
409
+
410
+ done ( )
411
+ } )
412
+ } )
380
413
} )
You can’t perform that action at this time.
0 commit comments