diff --git a/lib/css-extract-extends.js b/lib/css-extract-extends.js index 31f3448..d6b8839 100644 --- a/lib/css-extract-extends.js +++ b/lib/css-extract-extends.js @@ -2,7 +2,7 @@ var makeComposition = require('./composition').makeComposition; -var regex = /(.*?)(\s+?)(extends\s+?)((?:.|\n)*?){(?:(?:.|\n)*?)}/g; +var regex = /\.([^\s]+)(\s+)(extends\s+)((?:\.[^{]+))/g; module.exports = function extractExtends(css, hashed) { var found, matches = []; diff --git a/test/extends-in-media-query.expected.css b/test/extends-in-media-query.expected.css new file mode 100644 index 0000000..3d4c9ee --- /dev/null +++ b/test/extends-in-media-query.expected.css @@ -0,0 +1,30 @@ + + + .woot_2XWyPW { + color: red; + } + + .hello_2XWyPW { + font-size: 10px; + } + + .yay_2XWyPW { + font-weight: bold; + } + + @media (max-width: 480px) { + .woot_2XWyPW { + color: blue; + } + } + + @media (max-width: 580px) { + .woot_2XWyPW { + color: green; + } + } + + .underline_2XWyPW { + text-decoration: underline; + } + diff --git a/test/extends-in-media-query.expected.json b/test/extends-in-media-query.expected.json new file mode 100644 index 0000000..33de789 --- /dev/null +++ b/test/extends-in-media-query.expected.json @@ -0,0 +1,6 @@ +{ + "hello": "hello_2XWyPW", + "underline": "underline_2XWyPW", + "woot": "woot_2XWyPW foo_4xZqpC underline_2XWyPW hello_2XWyPW yay_2XWyPW", + "yay": "yay_2XWyPW" +} diff --git a/test/extends-in-media-query.source.js b/test/extends-in-media-query.source.js new file mode 100644 index 0000000..553110c --- /dev/null +++ b/test/extends-in-media-query.source.js @@ -0,0 +1,35 @@ +const csjs = require('../'); + +const basic = require('./basic.source'); + +module.exports = csjs` + + .woot { + color: red; + } + + .hello { + font-size: 10px; + } + + .yay { + font-weight: bold; + } + + @media (max-width: 480px) { + .woot extends .hello, .yay { + color: blue; + } + } + + @media (max-width: 580px) { + .woot extends ${basic.foo}, .underline { + color: green; + } + } + + .underline { + text-decoration: underline; + } + +`;