Skip to content

Commit a0a87ea

Browse files
author
kingdaro
committed
add comments - code's a little cryptic
1 parent ed3f3d1 commit a0a87ea

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,18 @@ export = (mod: { typescript: typeof ts }) => {
3636
end: number
3737
): string {
3838
const placeholder = templateString.slice(start, end);
39+
40+
// check to see if it's an in-property interplation, or a mixin,
41+
// and determine which character to use in either case
42+
// if in-property, replace with "xxxxxx"
43+
// if a mixin, replace with " "
3944
const pre = templateString.slice(0, start);
4045
const replacementChar = pre.match(/(^|\n)\s*$/g) ? ' ' : 'x';
4146

4247
let result = placeholder.replace(/./gm, c => c === '\n' ? '\n' : replacementChar);
48+
49+
// check if it's a mixin and if followed by a semicolon
50+
// if so, replace with a dummy variable declaration, so scss server doesn't complain about rogue semicolon
4351
if (replacementChar === ' ' && templateString.charAt(end) === ';') {
4452
result = '$a:0' + result.slice(4);
4553
}

0 commit comments

Comments
 (0)