Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

[feature request] --minify option #30

Open
vermutely opened this issue Jan 7, 2023 · 8 comments
Open

[feature request] --minify option #30

vermutely opened this issue Jan 7, 2023 · 8 comments

Comments

@vermutely
Copy link
Contributor

Add --minify option to railwind_css.

Tailwind CSS provides the following features
Optimizing for Production

@vermutely vermutely changed the title [feature request] --minify option [feature request] --minify option Jan 7, 2023
@pintariching
Copy link
Owner

Yeah that should be added also.

Does this option just remove spaces and newlines, or what does it actually do?

@vermutely
Copy link
Contributor Author

vermutely commented Jan 7, 2023

Does this option just remove spaces and newlines

I think you're right about the basics!

Tailwind Play merges media queries.

minify

It would save even more space, but I don't know if it should be handled in this Issue.
Would this merge be better managed in another Issue?

@pintariching
Copy link
Owner

I think this should be doable with the current implementation. First you need to iterate and group all the classes based on the railwind::modifiers::State. Then a new function needs to be added into railwind::class::ParsedClass that only generates the class selector without the state and wrap the resulting string in the state.

Also at the end, all the spaces and newlines should be stripped resulting in the minified string.

@yamafaktory
Copy link

Hello,

First of all thanks for this awesome project!

One solution for the minification might be to use https://docs.rs/lightningcss/1.0.0-alpha.39/lightningcss

@vermutely
Copy link
Contributor Author

I will try to make a PR based on the information you provided!
That minify library may be heavy with many dependencies, so I will first try to see if Regex can handle it.

@pintariching
Copy link
Owner

I don't think you need regex for this. You could use .replace(" ", "") to remove spaces and newlines. However I'm not sure what's faster, this or using regex.

@vermutely
Copy link
Contributor Author

vermutely commented Jan 8, 2023

Since there are CSS commentouts in preflight.css, I was doubt if I need to remove the commentouts in my minify process.
Would it be simpler to have a preflight.css that does not include the comments?

@pintariching
Copy link
Owner

Tailwind Play keeps these comments in so I think we should too and only remove then when minifying. In this case, you're right about using Regex to remove them.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants