globs cant be fully replaced
ctf0 opened this issue · 5 comments
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
laravel-mix-purgecss/src/index.js
Lines 32 to 39 in c48b793
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
- add the
globs
option - add
console.log(JSON.stringify(globs, null, 1));
to https://github.com/spatie/laravel-mix-purgecss/blob/master/src/createPurgeCssPlugin.js - run
npm run dev/watch
and check the console
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.
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: ... })
oh okay, so which PR do u prefer ?
-
for the docs, update with
paths
instead ofglobs
to clear the confusion
https://github.com/spatie/laravel-mix-purgecss/blame/master/README.md#L94-L96 -
or add a condition for globs to replace it and use the current as a fallback when empty
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.