Skip to content
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

Minifying 0px within calc statements breaks them #222

Closed
appsforartists opened this issue Jan 8, 2015 · 12 comments
Closed

Minifying 0px within calc statements breaks them #222

appsforartists opened this issue Jan 8, 2015 · 12 comments
Labels

Comments

@appsforartists
Copy link

See webpack/webpack#666

Chrome (and probably others) chokes on the unitless 0 in calc:

width:calc(100vw/2 - 6px + 0)
@ben-eb
Copy link

ben-eb commented Jan 29, 2015

@appsforartists Just curious, why would you use a selector such as this (with the 0px)?

div {
    width: calc(100vw / 2 - 6px + 0px);
}

@appsforartists
Copy link
Author

@ben-eb It'd be generated by a tool like SASS if you set a variable to 0px.

@ben-eb
Copy link

ben-eb commented Jan 29, 2015

@appsforartists Ideally then, CSSO should minify this to:

div {
    width: calc(100vw / 2 - 6px);
}

Or, just leave it alone. 😄

@appsforartists
Copy link
Author

Yup!

@jsor
Copy link

jsor commented Mar 6, 2015

Looks like it is also mangling time values like 0s or 0ms to 0 which is invalid.

@azamat-sharapov
Copy link

It's breaking calc()s generated by https://github.com/corysimmons/lost/
Using webpack also. Any workaround?

@ben-eb
Copy link

ben-eb commented Sep 17, 2015

@azamat-sharapov I maintain https://github.com/ben-eb/cssnano, a modern alternative to CSSO which is based on PostCSS.

@azamat-sharapov
Copy link

@ben-eb thanks! So, for this case, workaround would be disabling css-loader's internal minification and compile CSS through your cssnano?

@ben-eb
Copy link

ben-eb commented Sep 17, 2015

New installs of css-loader use cssnano. 😄

@azamat-sharapov
Copy link

You are right. Then I should check if it's cssnano breaking calc() or something else ;)

@ben-eb
Copy link

ben-eb commented Sep 17, 2015

@azamat-sharapov Seems it was a regression introduced some time ago. I've added a test for it, try 3.0.2. 😄

@azamat-sharapov
Copy link

@ben-eb thanks for the quick fix! it's working now!

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

No branches or pull requests

5 participants