Skip to content

Commit 2c7ff0f

Browse files
kihayuKeanu Hie
andauthored
feat: add CSS, SCSS and LESS support (#23)
Co-authored-by: Keanu Hie <[email protected]>
1 parent a7122c9 commit 2c7ff0f

27 files changed

+154
-1
lines changed

src/index.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import prettierParserHTML from 'prettier/parser-html'
22
import prettierParserFlow from 'prettier/parser-flow'
33
import prettierParserTypescript from 'prettier/parser-typescript'
44
import prettierParserBabel from 'prettier/parser-babel'
5+
import prettierParserPostCss from 'prettier/parser-postcss'
56
import { getParse } from './parser'
67
import { options } from './options'
78

@@ -25,6 +26,21 @@ const languages = [
2526
name: 'Tailwind Vue',
2627
extensions: ['.vue'],
2728
parsers: ['vue']
29+
},
30+
{
31+
name: 'Tailwind CSS',
32+
extensions: ['.css'],
33+
parsers: ['css']
34+
},
35+
{
36+
name: 'Tailwind SCSS',
37+
extensions: ['.scss'],
38+
parsers: ['scss']
39+
},
40+
{
41+
name: 'Tailwind Less',
42+
extensions: ['.less'],
43+
parsers: ['less']
2844
}
2945
]
3046
const parsers = {
@@ -47,6 +63,18 @@ const parsers = {
4763
vue: {
4864
...prettierParserHTML.parsers.vue,
4965
parse: getParse('html', prettierParserHTML.parsers.vue.parse)
66+
},
67+
css: {
68+
...prettierParserPostCss.parsers.css,
69+
parse: getParse('css', prettierParserPostCss.parsers.css.parse)
70+
},
71+
scss: {
72+
...prettierParserPostCss.parsers.scss,
73+
parse: getParse('scss', prettierParserPostCss.parsers.scss.parse)
74+
},
75+
less: {
76+
...prettierParserPostCss.parsers.less,
77+
parse: getParse('less', prettierParserPostCss.parsers.less.parse)
5078
}
5179
}
5280

src/regex.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"vue": "\\bclass\\s*=\\s*[\\\"\\']([_a-zA-Z0-9\\s\\-\\:\\/]+)[\\\"\\']",
33
"html": "\\bclass\\s*=\\s*[\\\"\\']([_a-zA-Z0-9\\s\\-\\:\\/]+)[\\\"\\']",
4+
"css": "@apply\\s*([_a-zA-Z0-9\\s\\-\\:\\/]+)",
5+
"scss": "@apply\\s*([_a-zA-Z0-9\\s\\-\\:\\/]+)",
6+
"less": "@apply\\s*([_a-zA-Z0-9\\s\\-\\:\\/]+)",
47
"javascriptreact": "(?:\\bclassName\\s*=\\s*[\\\"\\']([_a-zA-Z0-9\\s\\-\\:\\/]+)[\\\"\\'])|(?:\\btw\\s*`([_a-zA-Z0-9\\s\\-\\:\\/]*)`)",
58
"typescriptreact": "(?:\\bclassName\\s*=\\s*[\\\"\\']([_a-zA-Z0-9\\s\\-\\:\\/]+)[\\\"\\'])|(?:\\btw\\s*`([_a-zA-Z0-9\\s\\-\\:\\/]*)`)"
69
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a {
2+
@apply flex items-center justify-between h-16 max-w-6xl mx-auto;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a {
2+
@apply mx-auto flex justify-between items-center max-w-6xl h-16;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a {
2+
@apply unknown;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a {
2+
@apply unknown;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a {
2+
@apply dupplicate dupplicate;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a {
2+
@apply dupplicate dupplicate;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a {
2+
@apply dupplicate;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a {
2+
@apply dupplicate dupplicate;
3+
}

0 commit comments

Comments
 (0)