Skip to content

Commit 514e8ac

Browse files
committed
think my regex fu is ok
1 parent f13d8ca commit 514e8ac

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/wip.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
const matchImports = /^(.+?)\s+from\s+(?:"([^"]+)"|'([^']+)')$/
2+
const matchLet = /(?:,\s+|^)([\w-]+):?\s+("[^"]*"|'[^']*'|[^,]+)\s?/g
23

34
export default css => {
4-
css.eachAtRule('alias', atRule => {
5+
let declarations = {}
6+
css.eachAtRule(/^-?let$/, atRule => {
7+
console.log(atRule.params)
8+
9+
let matches
10+
while (matches = matchLet.exec(atRule.params)) {
11+
let [/*match*/, key, value] = matches
12+
declarations[key] = value
13+
}
14+
})
15+
css.eachAtRule(/^-?import$/, atRule => {
516
let imports = matchImports.exec(atRule.params)
617
if (imports) {
7-
18+
//console.log(imports)
819
} else {
920
console.log(atRule.params)
1021
}

test/test-cases/aliases/source.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@let borders: "./borders.css";
2-
@import small from "./breakpoints.css";
1+
@let borders: "./borders.css", breakpoints: "./breakpoints";
2+
@import small from breakpoints;
33
@import secondary, blue as primary from "./colors.css";
44

55
.foo {

0 commit comments

Comments
 (0)