spatie / laravel-mix-purgecss

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

Add dependency to laravel-mix itself #28

Closed svenluijten closed 6 years ago

svenluijten commented 6 years ago

Spent a while scratching my head trying to figure out what was wrong here 😅

I had an older Laravel installation I was working on, and wanted to pull in this package. Version ^2.0.0 got pulled in, but I was still on version 1.x for Laravel Mix, so when compiling my assets, I was getting an error along the lines of mix.extend is not a function, originating from this package.

I suggest we add a dependency to laravel-mix version ^2.0 to this package's package.json, and ^1.0 to version 1.0 (if it's still maintained), so versions are resolved correctly when requiring this package.

I should note I have no idea if npm or yarn work the same way as Composer would in this situation, so you'll have to let me know 😛 Once that is cleared up, I'll gladly submit a PR to get this working! 🙂

sebastiandedeyne commented 6 years ago

There's already a peerDependency for Mix, and that's really all we can do. If there was an incompatible Mix version installed in your app, npm or yarn should've emitted a warning that the peer dependency's version was incorrect.

https://nodejs.org/en/blog/npm/peer-dependencies/

If Mix was a normal dependency of this library, we'd run the risk that two separate Mix versions would be installed in a single project, which is even harder to debug.

Unfortunately, I don't think we can really solve this issue, as it's rooted in npm/yarn.