TrySound / postcss-easy-import

PostCSS plugin to inline @import rules content with extra features
MIT License
200 stars 25 forks source link

Unstable glob import #9

Closed jamesplease closed 7 years ago

jamesplease commented 8 years ago

Globbing will throw an error when a file contains syntax errors, whereas a regular import does not.

Steps to reproduce:

  1. Create a PostCSS with a syntax error, say, color #333; (this example is missing a semicolon)
  2. Import the file via @import './path/to/file';

This is working without throwing any errors for me.

Change the import to be:

@import '/path/**/*';

It should error with:

[21:58:59] Plumber found unhandled error:
 Error in plugin 'gulp-postcss'
Message:
    ENOENT: no such file or directory, open '/Users/jmeas/WebDev/moolah/client-src/meta/components/**/*.css'
Details:
    errno: -2
    code: ENOENT
    syscall: open
    path: /Users/jmeas/WebDev/moolah/client-src/meta/components/**/*.css
    fileName: /Users/jmeas/WebDev/moolah/client-src/css/index.css
Stack:
Error: ENOENT: no such file or directory, open '/Users/jmeas/WebDev/moolah/client-src/meta/components/**/*.css'
    at Error (native)

Correcting the syntax error allows for the glob to work.

I'm OK with syntax errors erroring, but I'd expect the error to relate to syntax errors, rather then ENOENT (which isn't true!)


I am using gulp for this, but I figure the error is likely here. Lmk if you think otherwise and I'll check out the postcss gulp plugin.

simonsmith commented 7 years ago

Hi @jmeas,

This could be because you did not set glob to true as seen here in the docs.

This option is not ideal though so #14 aims to resolve it.

jamesplease commented 7 years ago

Thanks for the suggestion, @simonsmith ! That wasn't the issue – I've always been using that option – but I did a fresh install of the repo and wasn't able to reproduce the problem. As expected, I now get a syntax error.

My guess is that a more recent version of postcss-easy-import may have "accidentally" fixed it, or something.

Thanks again for taking a look, @simonsmith !