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

Autoprefixer not generating prefixes for sass with variables #1355

Open
vanitabarrett opened this issue Aug 28, 2020 · 2 comments
Open

Autoprefixer not generating prefixes for sass with variables #1355

vanitabarrett opened this issue Aug 28, 2020 · 2 comments

Comments

@vanitabarrett
Copy link

Using version 9.8.5
Prefixes are generated fine if $ratio is replaced with a fixed numeric value, e.g: 2. Not sure if this is intended behaviour or not?

Input SASS

@mixin govuk-device-pixel-ratio($ratio: 2) {
  @media only screen and (min-resolution: $ratio*96dpi),
    only screen and (min-resolution: $ratio*1dppx) {
      @content;
    }
}

Output SASS

@mixin govuk-device-pixel-ratio($ratio: 2) {
  @media only screen and (min-resolution: $ratio*96dpi),
    only screen and (min-resolution: $ratio*1dppx) {
      @content;
    }
}

Expected output SASS

@mixin govuk-device-pixel-ratio($ratio: 2) {
  @media only screen and (-webkit-min-device-pixel-ratio: $ratio),
    only screen and (min-resolution: $ratio*96dpi),
    only screen and (-webkit-min-device-pixel-ratio: $ratio),
    only screen and (min-resolution: $ratio*1dppx) {
      @content;
    }
}

Config

  // browserlist
  "browserslist": [
    ">0.1%",
    "last 2 Chrome versions",
    "last 2 Firefox versions",
    "last 2 Edge versions",
    "last 2 Samsung versions",
    "Safari >= 9",
    "ie 8-11",
    "iOS >= 9"
  ]

 // gulp task
.pipe(scssFiles)
.pipe(postcss([
      autoprefixer
    ], {
      syntax: require('postcss-scss'),
    }))
@ai
Copy link
Member

ai commented Aug 28, 2020

Sorry, Autoprefixer was not created to process SCSS sources.

We can do it but without the ideal result.

Possible solutions:

  1. You can send pull request. I will not have time to support SCSS but will ask to your questions if you will try to add the support.
  2. You can add Autoprefixer after the SCSS to CSS compilation step. This is the main easy to use Autoprefixer.

@Dan503
Copy link
Contributor

Dan503 commented Aug 28, 2020

You should use gulp-sass to compile the sass into CSS for you then pipe gulp-postcss after it to run Autoprefixer.

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

No branches or pull requests

3 participants