spatie/laravel-mix-purgecss

globs cant be fully replaced

ctf0 opened this issue · 5 comments

ctf0 commented

according to
https://github.com/spatie/laravel-mix-purgecss/blame/master/README.md#L92-L93

adding

globs: [
   path.join(__dirname, 'node_modules/simplemde/**/*.js'),
],

should replace the package defaults, but because of

this.options.globs.push(
rootPath('app/**/*.php'),
...flatMap(this.options.folders, folder => {
return this.options.extensions.map(extension =>
rootPath(`${folder}/**/*.${extension}`)
);
})
);

this is not possible and you are basically adding an extra entry point to be scanned.

also https://github.com/spatie/laravel-mix-purgecss#usage-outside-of-laravel is not true because if root/app/ is not found you will get an error.

to test

btw globs extension could be omitted https://github.com/FullHuman/purgecss-webpack-plugin/blame/master/README.md#L68 as purgecss will use the extensions option to fill it.

Globs aren't meant to ever fully replaced, this is mentioned in the readme:

If you need to fully replace the globs, use the underlying paths option instead.

I do agree that the hard coded app should go. I think this can be moved to folders, doesn't really matter if app gets scanned for more extensions than PHP.

ctf0 commented

am not sure what this part means

use the underlying paths option instead.

still i can make a PR with a check for globs & if empty then fallback to

this.options.globs.push( 
     ...flatMap(this.options.folders, folder => { 
         return this.options.extensions.map(extension => 
             rootPath(`${folder}/**/*.${extension}`) 
         ); 
     }) 
 ); 

globs is not a Purgecss option, it's custom made for this wrapper. paths is the actual configuration property. If you specify a custom paths option, globs will be completely ignored.

https://github.com/FullHuman/purgecss-webpack-plugin#paths

mix.purgeCss({ paths: ... })

ctf0 commented

oh okay, so which PR do u prefer ?

Feel free to send a PR that improves the docs regarding paths vs. globs. However, we're going to keep globs as the recommended configuration, and not going to change it's behavior. For most people, globs is more than enough and is easier to configure.