Skip to content

Commit 21c38a1

Browse files
committed
fix formatter @apply colon issue
1 parent 3766cee commit 21c38a1

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ module.exports = {
173173
formatterOptions = Object.assign(formatterOptions, options.fomatterOptions);
174174
}
175175

176-
return beautifyCss(sassTreeResult, formatterOptions);
176+
if (options && options.formatOutput === true){
177+
return beautifyCss(sassTreeResult, formatterOptions);
178+
}
179+
180+
return sassTreeResult;
177181
}
178182

179183
return null;

src/utils.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,33 @@ module.exports = {
3737
}
3838

3939
return string;
40+
},
41+
42+
/**
43+
* Fix formatter SASS @apply tailwind broken colon (":") syntax
44+
*
45+
* Exp: @apply bg-white hover: shadow-2xl ...
46+
* ^^^
47+
* @param {string} content
48+
*
49+
* @return string
50+
*/
51+
fixFomatterApplyIssue: function (content) {
52+
if (content && content.length) {
53+
var lines = content.split('\n'),
54+
pattern = /@apply [a-zA-Z0-9-_\/ ]+ [a-zA-Z0-9-_\/]+(: )[a-zA-Z0-9-_\/]+/gm;
55+
56+
for (let i = 0; i < lines.length; i++) {
57+
const line = lines[i];
58+
59+
if (line.match(pattern)) {
60+
lines[i] = line.replace(': ', ':');
61+
}
62+
}
63+
64+
return lines.join('\n');
65+
}
66+
67+
return content;
4068
}
4169
};

0 commit comments

Comments
 (0)