OlehDutchenko / sort-css-media-queries

The custom `sort` method (mobile-first / desktop-first) for the `postcss-sort-media-queries` and `css-mqpacker`, or possibly something else
MIT License
51 stars 7 forks source link

TypeError: fs.existsSync is not a function, when using in the Browser #11

Closed ligne13 closed 3 years ago

ligne13 commented 3 years ago

Hi,

I get this error when using sort-css-media-queries via postcss-sort-media-queries in the browser :

TypeError: fs.existsSync is not a function
    at loadConfig (load-config.js?fb83:15)
    at eval (index.js?8452:3)
    at Object../node_modules/sort-css-media-queries/lib/index.js (chunk-vendors.js:7923)
    at __webpack_require__ (index.js:854)
    at fn (index.js:151)
    at module.exports (VM17499 index.js:20)
    at Processor.normalize (processor.js?58d3:43)
    at new Processor (processor.js?58d3:10)
    at postcss (postcss.js?3984:26)
    at postCSS (VM17457 getExportedHTML.js:325)

fs is an empty object in the load-config.js file. I guess this is normal as I am running in the browser.

Maybe you need to add a if statement to check if fs is actually defined.

Thanks

yunusga commented 3 years ago

I solver this with https://github.com/solversgroup/postcss-sort-media-queries/blob/main/browser.js#L21 for https://postcss-sort-media-queries.github.io/

ligne13 commented 3 years ago

Thanks !