-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compress all files in the directory #18
Comments
Thanks @pavelloz for an idea - I think it could either work by replacing files inline or by placing optimized output in a
What do you think? |
Well, replacing in-place would be even better, but listing all the files in arguments is still much harder than passing Having regexp-like syntax would force me to still go around and gather all the filenames without extension and build the string to be able to match all of them, so i would end up creating my own abstraction layer anyway, with recursive I think the most common way of using cli tools are actually (at least for me) two cases:
I have no idea if thats true, but in you 4.1 introduced The only difference is now skipping the -o, meaning: by default, override the file it was read from. Of course this would be a breaking change, so flag (ie. --in-place) is preferred. PS. I think auto-renaming should be an opt-in, in below example it would ruin filenames for me (some files don't have I'll describe exact use case to bring some context and maybe it will be easier to abstract a general feature from that. I have a project that has assets (not mine, half of them 3rd party, half of them minified), but i will be handing it over to someone else whose skills might vary (im responsible for assets preparing from source to target format in an efficient way and hopefully fast, reliable and cross browser), so I want to use micro-tools (cli as much as possible, as little as possible node programmatically) and small configs as much as i can to ease the pain for any future maintainer. Example assets pipeline: And all that handled by couple Because all files from the build process land in Because there wont be much of a nesting in Maybe i got carried away by all the 0 config idea that webpack is now implementing as well, but i just thought it would be cool to have a command: |
Thanks for detailed comment @pavelloz - I see your point here. First using files explicitly in my example was only to illustrate the idea - clean-css-cli supports glob matching since e877d27. This may also save us from explicit In general I'm all for adding this feature. |
Ouh, thats great, I didn't catch the glob change before :) I hope it isn't just my weird use case and a lot of other users will also benefit from it while composing their assets processing. Thank you :) |
I had a similar problem and found this issue, so +1 from me. As a quick workaround I just installed foreach-cli package so I can do this:
I'm on Windows so I had to use the |
Well, I get that your input can be globed.
The neat npm script i'd like to have is something such as:
so every corresponding file gets minified and don't need to be merged into a combined one. I know this is doable using gulp or grunt, but it's not my goal to use these. 🤔 mtsk's solution didn't work for me.
|
Just to make sure, this issue is not about compressing all the files in the directory into a single output file, but rather each I would say @pavelloz you are definitely not alone in needing this workflow. For anyone working in WordPress (lots of people) and creating their own custom blocks with ACF (maybe not as many), this is exactly what you need. Each custom block is in it's own folder under
It would be great if |
Looks like this is a requested feature, let me have a look how to do it. clean-css will be bumped to version 5.0 next week, so maybe it's a good time to include this feature in clean-css-cli v5 release. |
Since clean-css v5.0.0 is out and there's a new |
Please check the main branch for the feature - there are two new options The cleancss --batch path/to/stylesheets/*.css and all styles under that path will get optimized one by one. The cleancss --batch --batch-suffix '.min' path/to/stylesheets/*.css will optimize The default for |
@PatricNox @onetrev I'd love your feedback on this. |
Hey @jakubpawlowicz thanks so much for doing this! I have some feedback, actually I'm having some issues. This is what I'm finding...
Hopefully this is not me missing something obvious. Let me know if I can help test anything further. |
Hey @onetrev - thanks for testing! Just to make sure we are on the same page:
Do you think |
No worries, happy to help! And yes good call to double check these details.
Personally I think I see minimized files as |
Hej @jakubpawlowicz, this is exactly what I was looking for and now is the "core way" replacement of my previous script:
to
I like the argument names as well, as it's clear what's to be happening. |
Glad it works for you, @PatricNox! @onetrev I think you need to clone this repo in order to test it before 5.0 release, here's how to do it: https://github.com/jakubpawlowicz/clean-css-cli#how-to-get-started Once you have it locally and after If you need any help just let us know. |
Awesome, works perfectly. Very exciting this addition does exactly what I need. I'm sure it will help many others too. A bit embarrassing I didn't realise v5 wasn't released yet. I was just so excited to try it out I guess. And I saw the v5.0 details in the docs of the repo so made the assumption. Totally my bad. |
@onetrev Awesome, thanks for giving it a try. I've realised the description in Readme is a bit misleading as v5 is not released yet, so I should phrase v5 changes section a bit differently. Sorry, my bad! Expect v5 to land on npm tomorrow. |
Thanks a lot for testing and your patience on this! v5 is on npm now. 🎉 |
@jakubpawlowicz is there a way of omitting the suffix? I would like to have the same filename after clean-css was run. So when I have a demo.css file it should be still demo.css after minifying. At the moment it adds "-min" when I don't have the "--batch-suffix" parameter and I can't find a way of telling it to not add a suffix at all. |
Sorry @BenediktBergmann I missed your comment. Please use |
@jakubpawlowicz That's probably a good idea as it may otherwise be treated as diverted |
@PatricNox added in 3a6f98f |
I'm using v5.3.2 on Windows 10 with Node 20 and |
I have a case where i would just like to apply
cleancss
to every file in the directory, without name changing etc.Ideally this would work:
cleancss path/to/css/*.min.css
I know i can dance around i with xargs and thats what I'm going to do ATM, but i suppose it can be a pretty common use case so i decided to create an issue to hear what you think about it.
Thanks for the great tool :)
The text was updated successfully, but these errors were encountered: