Skip to content

Commit

Permalink
feat: use scss syntax for parsing css to allow inline comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Nov 1, 2021
1 parent 711960a commit 21173b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
7 changes: 5 additions & 2 deletions src/utils/buildTaggedTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,11 @@ export default function buildTaggedTemplate(opts: Options) {
location !== 'STYLESHEET' &&
opts.style.absoluteFilePath.endsWith('.css')
) {
// console.log(css);
css = processCss(css, opts.style.absoluteFilePath).css;
try {
css = processCss(css, opts.style.absoluteFilePath).css;
} catch {
/* ignore */
}
}

return {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/processCss.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import postcss from 'postcss';
import postcssNested from 'postcss-nested';
import postcssScss from 'postcss-scss';

export default function process(css: string, from: string) {
return postcss([postcssNested()]).process(css, {
from,
syntax: postcssScss,

This comment has been minimized.

Copy link
@jsg2021

jsg2021 Nov 2, 2021

Contributor

Could this be an opt-in? In my projects I've only allowed pure CSS (as defined by postcss-preset-env)

This comment has been minimized.

Copy link
@jquense

jquense Nov 4, 2021

Author Contributor

this just allows a looser syntax when parsing it doesn't actually allow or compile Sass. unless you are compiling sass somewhere your postcss will catch and fail the scss syntax code.

map: {
inline: true,
},
Expand Down
23 changes: 2 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7885,12 +7885,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==

mime@^2.4.4:
version "2.4.6"
resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.6.tgz#e5b407c90db442f2beb5b162373d07b69affa4d1"
integrity sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA==

mime@~2.5.2:
mime@^2.4.4, mime@~2.5.2:
version "2.5.2"
resolved "https://registry.yarnpkg.com/mime/-/mime-2.5.2.tgz#6e3dc6cc2b9510643830e5f19d5cb753da5eeabe"
integrity sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==
Expand Down Expand Up @@ -8028,11 +8023,6 @@ nanoid@^2.0.3:
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.1.11.tgz#ec24b8a758d591561531b4176a01e3ab4f0f0280"
integrity sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==

nanoid@^3.1.20:
version "3.1.20"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.20.tgz#badc263c6b1dcf14b71efaa85f6ab4c1d6cfc788"
integrity sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==

nanoid@^3.1.30:
version "3.1.30"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.30.tgz#63f93cc548d2a113dc5dfbc63bfa09e2b9b64362"
Expand Down Expand Up @@ -8969,7 +8959,7 @@ postcss@^5.0.18:
source-map "^0.5.6"
supports-color "^3.2.3"

postcss@^8.0.0:
postcss@^8.0.0, postcss@^8.2.8:
version "8.3.11"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.11.tgz#c3beca7ea811cd5e1c4a3ec6d2e7599ef1f8f858"
integrity sha512-hCmlUAIlUiav8Xdqw3Io4LcpA1DOt7h3LSTAC4G6JGHFFaWzI6qvFt9oilvl8BmkbBRX1IhM90ZAmpk68zccQA==
Expand All @@ -8978,15 +8968,6 @@ postcss@^8.0.0:
picocolors "^1.0.0"
source-map-js "^0.6.2"

postcss@^8.2.8:
version "8.2.8"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.8.tgz#0b90f9382efda424c4f0f69a2ead6f6830d08ece"
integrity sha512-1F0Xb2T21xET7oQV9eKuctbM9S7BC0fetoHCc4H13z0PT6haiRLP4T0ZY4XWh7iLP0usgqykT6p9B2RtOf4FPw==
dependencies:
colorette "^1.2.2"
nanoid "^3.1.20"
source-map "^0.6.1"

prelude-ls@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
Expand Down

0 comments on commit 21173b8

Please sign in to comment.