matthiasmullie / minify

CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.
https://matthiasmullie.github.io/minify/
MIT License
1.96k stars 310 forks source link

Add an option to CSS Minifyer to not modify relative import paths. #402

Closed gguerreromx closed 1 year ago

gguerreromx commented 1 year ago

Hello.

I have been testing a new method for minifying the entire project, but not merging it. (Creating a minifyed copy of the directory).

The CSS minifyer always tries to adjust according to the ending path, unknowing what the final result is intended to be, so the end result is unusable.

While I understand the reasoning behind adjusting the relative paths, I would like it to be an option (with default value the current behavior), so I created a function to set the non convert path option.

I created this pull request for your consideration.

Have a nice day.

matthiasmullie commented 1 year ago

Hi @gguerreromx - thanks for the PR.

If you call ->minify() (without providing a $path argument, it already shouldn't transform paths (since there is no indication of what to change them to).

Can you help me understand exactly why you need this? Is there a reason that that doesn't suffice? Or did that fail? Or was that simply not clear enough in the lacklustre documentation? :p

gguerreromx commented 1 year ago

Hello.

You are right. I misunderstood the purpose of the $path variable in ->minify() and ->gzip() assuming it was the "only" way to save a file.

It is actually in the documentation (and in the code), the availability of the return value of these functions, but didn't clicked on my head that they skipped the path conversion step when the $path variable is empty.

I simply modified my code to create the files from the return values.

Thank you for your response and the excellent library.

FYI I have used your work for many of my projects and I am very grateful for it.