BlessCSS / bless

CSS Post-Processor
blesscss.com
MIT License
282 stars 60 forks source link

Mediaquery and maven variable #92

Open yvanavermaet opened 8 years ago

yvanavermaet commented 8 years ago

Hi

We've encountered a small issue with our current set-up.

In the code below this works great

body {
    background: transparent url('../img/image-small.jpg?c=${buildNumber}') 50% top no-repeat;
    background-size: cover;
}

Output

body {
    background: transparent url("../img/image-small.jpg?c=${buildNumber}") 50% top no-repeat;
    background-size: cover;
}

If we now add a media query, this doesn't work

body {
    background: transparent url('../img/image-small.jpg?c=${buildNumber}') 50% top no-repeat;
    background-size: cover;

    @media only screen and (min-width: 600px) {
        background-image: url('../img/image-medium.jpg?c=${buildNumber}');
        background-position: left top;
    }
}

Output

body {
    background: transparent url("../img/image-small.jpg?c=${buildNumber}") 50% top no-repeat;
    background-size: cover;
}
    body {
        background-image: url("../img/image-medium.jpg?c=${buildNumber}");
        background-position: left top;
    }
}

Expected output

body {
    background: transparent url("../img/image-small.jpg?c=${buildNumber}") 50% top no-repeat;
    background-size: cover;
}

@media only screen and (min-width: 600px) {
    body {
        background-image: url("../img/image-medium.jpg?c=${buildNumber}");
        background-position: left top;
    }
}

Notice the missing media query It's not possible to replace ${buildNumber} with another string/value.

Gulp-bless version 3.0.1, bless version 3.0.3. At first I thought it was related to node-sass, but after further investigation, it seems it's related to (gulp-)bless

Thanks in advance.

Kind regards, Yannick

aabenoja commented 8 years ago
body {
    background: transparent url('../img/image-small.jpg?c=${buildNumber}') 50% top no-repeat;
    background-size: cover;

    @media only screen and (min-width: 600px) {
        background-image: url('../img/image-medium.jpg?c=${buildNumber}');
        background-position: left top;
    }
}
  1. This is a known limitation of bless v3.
  2. Bless is not a preprocessor. Your media query example is not valid css. Feeding such into v4 will cause the parser to throw on your media query. Here's a fiddle.
yvanavermaet commented 8 years ago

@aabenoja I should have stated that my code example was written in scss, my bad. A good css example is

body {
    background: transparent url("../img/image-small.jpg?c=${buildNumber}") 50% top no-repeat;
    background-size: cover;
}

@media only screen and (min-width: 200px) {
    body {
        background-image: url("../img/image-medium.jpg?c=${buildNumber}");
        background-position: left top;
    }
}

Aha, it's a limitation of v3. Will it be possible in v4 of bless?

aabenoja commented 8 years ago

Correct.