xzyfer / sass-graph

Parses import dependencies from a directory of sass files
MIT License
76 stars 59 forks source link

Consecutive URL imports in CSS cause an error #89

Open RoyTinker opened 6 years ago

RoyTinker commented 6 years ago

(mostly) reduced test case: https://github.com/RoyTinker/node-sass-watch-import-css-bug

CSS:

@import url(http://some-site.com/fonts/1);
@import url(something.css);

Error:

/[redacted]/node_modules/sass-graph/parse-imports.js:20
        throw new Error('Encountered invalid @import syntax.');
        ^

Error: Encountered invalid @import syntax.
    at parseImports (/[redacted]/node_modules/sass-graph/parse-imports.js:20:15)
    at Graph.addFile (/[redacted]/node_modules/sass-graph/sass-graph.js:69:17)
    at /[redacted]/node_modules/sass-graph/sass-graph.js:54:13
    at arrayEach (/[redacted]/node_modules/lodash/lodash.js:537:11)
    at Function.forEach (/[redacted]/node_modules/lodash/lodash.js:9359:14)
    at new Graph (/[redacted]/node_modules/sass-graph/sass-graph.js:53:7)
    at Object.module.exports.parseDir (/[redacted]/node_modules/sass-graph/sass-graph.js:156:17)
xzyfer commented 6 years ago

Thanks for the issue. Sass graph should ignore url imports.

JohnKulp commented 5 years ago

Is there any planned fix for this? This is breaking my node-sass build pipeline and seems to be a very common error case.

shankj3 commented 5 years ago

We just encountered this issue as well -- seems to be happening for multiple imports regardless of if they are consecutive

Avdheshg commented 5 years ago

(mostly) reduced test case: https://github.com/RoyTinker/node-sass-watch-import-css-bug

CSS:

@import url(http://some-site.com/fonts/1);
@import url(something.css);

Error:

/[redacted]/node_modules/sass-graph/parse-imports.js:20
        throw new Error('Encountered invalid @import syntax.');
        ^

Error: Encountered invalid @import syntax.
    at parseImports (/[redacted]/node_modules/sass-graph/parse-imports.js:20:15)
    at Graph.addFile (/[redacted]/node_modules/sass-graph/sass-graph.js:69:17)
    at /[redacted]/node_modules/sass-graph/sass-graph.js:54:13
    at arrayEach (/[redacted]/node_modules/lodash/lodash.js:537:11)
    at Function.forEach (/[redacted]/node_modules/lodash/lodash.js:9359:14)
    at new Graph (/[redacted]/node_modules/sass-graph/sass-graph.js:53:7)
    at Object.module.exports.parseDir (/[redacted]/node_modules/sass-graph/sass-graph.js:156:17)

I was getting the same error when I was working with the multiple sass files My mistake was @import "folder-name/file-name" (Here i forgot to add a semicolon ; ) but when I have added the semicolon Everything works perfect