Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Compress option not working in CLI - possible conflict with other options #195

Closed
dhruvbhatia opened this issue Aug 15, 2015 · 9 comments
Closed

Comments

@dhruvbhatia
Copy link

Using the -c flag within the CLI does not actually compress a given input file under v1.8.3.

E.g. let's consider the compression example on the cssnano homepage:

input.css

h1::before, h1:before {
    margin: 10px 20px 10px 20px;
    color: #ff0000;
    -webkit-border-radius: 16px;
    border-radius: 16px;
    font-weight: normal;
    font-weight: normal;
}
/* invalid placement */
@charset "utf-8";

We'd expect cssnext -c input.css to give us this:

@charset "utf-8";h1:before{margin:10px 20px;color:red;border-radius:1pc;font-weight:400}

However we just get back the original input.css (non-compressed).

After some digging I found that adding the following flags in addition to -c seems to help, so I imagine there's a conflict with how cssnano is being called:

Hacky workaround - disable everything but compression:
> cssnext -c input.css --no-custom-properties --no-calc --no-custom-media --no-media-queries-range --no-custom-selectors --no-color-rebeccapurple --no-color-hwb --no-color-gray --no-color-hex-alpha --no-color-function --no-font-variant --no-filter --no-rem --no-pseudo-elements --no-pseudo-class-matches --no-pseudo-class-not --no-pseudo-class-any-link --no-color-rgba --no-autoprefixer

The above delivers compressed output, but it obviously isn't ideal given we're effectively disabling all the other features within cssnext.

Has anyone run into the same issue?

@ben-eb
Copy link
Contributor

ben-eb commented Aug 15, 2015

Might be related to this: #194

@MoOx
Copy link
Owner

MoOx commented Aug 15, 2015

Not sure how it's related since nobody raised this issue until now.
@dhruvbhatia do you get the same issue without the charset rule?

@dhruvbhatia
Copy link
Author

Thanks for the quick responses!

Yes I get the same issue, even without the charset rule. I.e. Even basic input isn't compressed.

If you can't reproduce then perhaps there's something wrong at my end? Are you able to produce the expected output in the example above?

On 16 Aug 2015, at 1:57 am, Maxime Thirouin notifications@github.com wrote:

Not sure how it's related since nobody raised this issue until now.
@dhruvbhatia do you get the same issue without the charset rule?


Reply to this email directly or view it on GitHub.

@dhruvbhatia
Copy link
Author

I tested historical versions in clean environments and discovered that the unexpected behaviour only started in v1.8.0 (compression worked fine prior).

This coincides with the upgrade to cssnano v2.x - #166 as per the v1.8.0 release notes.

v1.7.1 works fine so using that for the time being, but I'll keep digging and see if I can isolate further..

@ymauray
Copy link

ymauray commented Aug 20, 2015

I confirm that starting from v1.8.0, compression does not work. I use cssnext as a PostCSS plugin.

@apapirovski
Copy link

@ben-eb seems correct to me based on my testing. When I changed postcssPlugin names to be unique, everything started working again.

@MoOx
Copy link
Owner

MoOx commented Aug 22, 2015

Tests were passing when 1.8.3 were released, and now the same tests are broken with a fresh install.
So this is related to a breaking change introduced by a recent cssnano "minor" update (that should have been major ?).
I will fix that by addressing #194

@ben-eb
Copy link
Contributor

ben-eb commented Aug 22, 2015

You can work around this by passing this config to cssnext (since cssnano 2.5.0):

{
  compress: {filterPlugins: false}
}

@MoOx MoOx closed this as completed in b5ece99 Aug 25, 2015
@MoOx
Copy link
Owner

MoOx commented Aug 25, 2015

Fix released as 1.8.4

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

5 participants