spatie / laravel-mix-purgecss

Zero-config Purgecss for Laravel Mix
https://spatie.be/en/opensource
MIT License
874 stars 38 forks source link

Exclude folders from glob-all #36

Closed wiljanslofstra closed 6 years ago

wiljanslofstra commented 6 years ago

This fixes an error that occurs when a folder ends in one of the configured extensions (more info: #18). In my case I had a folder named jump.js. When using/running laravel-mix-purgecss I received the following error:

/Users/wiljanslofstra/Sites/project_name/node_modules/purgecss/lib/purgecss.js:678
                        throw _iteratorError5;
                        ^

Error: EISDIR: illegal operation on a directory, read
    at Object.fs.readSync (fs.js:675:18)
    at tryReadSync (fs.js:540:20)
    at Object.fs.readFileSync (fs.js:583:19)
    at Purgecss.extractFileSelector (/Users/wiljanslofstra/Sites/project_name/node_modules/purgecss/lib/purgecss.js:649:46)
    at Purgecss.purge (/Users/wiljanslofstra/Sites/project_name/node_modules/purgecss/lib/purgecss.js:409:41)
    at /Users/wiljanslofstra/Sites/project_name/node_modules/purgecss-webpack-plugin/lib/purgecss-webpack-plugin.js:205:97
    at Array.forEach (<anonymous>)
    at /Users/wiljanslofstra/Sites/project_name/node_modules/purgecss-webpack-plugin/lib/purgecss-webpack-plugin.js:155:39
    at Array.forEach (<anonymous>)
...and more

To prevent glob-all from matching folders ending in one of the extensions, I've added the option mark: true that adds slashes to the end of the path if it's a folder. And a filter that removes all paths ending in slashes (folders). This solution is copied from the glob-all documentation: https://github.com/jpillora/node-glob-all

sebastiandedeyne commented 6 years ago

Thanks!