Skip to content

Commit

Permalink
feat: import parse directly from css (#415)
Browse files Browse the repository at this point in the history
- This will avoid having to access `fs` which will break in browser environments

Co-authored-by: Nick McCurdy <nick@nickmccurdy.com>
  • Loading branch information
yannbf and nickmccurdy committed Nov 2, 2021
1 parent 35ab97d commit 4cb606c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils.js
@@ -1,5 +1,5 @@
import redent from 'redent'
import {parse} from 'css'
import cssParse from 'css/lib/parse'
import isEqual from 'lodash/isEqual'

class GenericTypeError extends Error {
Expand Down Expand Up @@ -100,7 +100,7 @@ class InvalidCSSError extends Error {
}

function parseCSS(css, ...args) {
const ast = parse(`selector { ${css} }`, {silent: true}).stylesheet
const ast = cssParse(`selector { ${css} }`, {silent: true}).stylesheet

if (ast.parsingErrors && ast.parsingErrors.length > 0) {
const {reason, line} = ast.parsingErrors[0]
Expand Down

0 comments on commit 4cb606c

Please sign in to comment.