Bird
Raised Fist0
SASSmarkup~20 mins

SASS with PostCSS pipeline - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
SASS & PostCSS Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the main role of PostCSS in a SASS build pipeline?

Consider a build process where SASS files are compiled to CSS, then processed by PostCSS. What is the primary purpose of PostCSS in this setup?

ATo compile SASS syntax into standard CSS
BTo add vendor prefixes and optimize the compiled CSS for browser compatibility
CTo minify JavaScript files linked in the project
DTo convert HTML files into CSS stylesheets
Attempts:
2 left
💡 Hint

Think about what happens after SASS compilation before the CSS is sent to browsers.

📝 Syntax
intermediate
2:00remaining
Which PostCSS plugin configuration correctly adds vendor prefixes in a SASS pipeline?

Given a PostCSS setup, which plugin configuration will correctly add vendor prefixes to the CSS output from SASS?

SASS
module.exports = {
  plugins: {
    // Which plugin here?
  }
};
A"autoprefixer": {}
B"cssnano": {}
C"postcss-import": {}
D"stylelint": {}
Attempts:
2 left
💡 Hint

Look for the plugin that automatically adds browser prefixes.

rendering
advanced
3:00remaining
What will be the final CSS output after SASS and PostCSS processing?

Given the following SASS code and PostCSS with autoprefixer enabled, what is the final CSS output?

SASS
$main-color: #3498db;

.button {
  display: flex;
  background-color: $main-color;
  user-select: none;
}
A
.button {
  display: -webkit-flex;
  background-color: #3498db;
  user-select: none;
}
B
.button {
  display: flex;
  background-color: $main-color;
  user-select: none;
}
C
.button {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  background-color: #3498db;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
D
.button {
  display: flex;
  background-color: #3498db;
  user-select: none;
}
Attempts:
2 left
💡 Hint

Remember autoprefixer adds vendor prefixes for better browser support.

selector
advanced
2:30remaining
Which CSS selector is generated by this nested SASS code after PostCSS processing?

Given this SASS snippet, what is the correct CSS selector generated?

SASS
.nav {
  ul {
    margin: 0;
    li {
      list-style: none;
      &:hover {
        color: red;
      }
    }
  }
}
A.nav ul li:hover { color: red; }
B.nav ul:hover li { color: red; }
C.nav ul li & :hover { color: red; }
D.nav:hover ul li { color: red; }
Attempts:
2 left
💡 Hint

Look at how nested selectors combine in SASS.

accessibility
expert
3:00remaining
How can PostCSS help improve accessibility in CSS generated from SASS?

Which PostCSS plugin or technique can be used to enhance accessibility by improving focus styles in CSS output from SASS?

AUsing <code>stylelint</code> to automatically add ARIA attributes in CSS
BUsing <code>cssnano</code> to minify CSS and remove all focus styles
CUsing <code>postcss-import</code> to import external CSS files
DUsing <code>postcss-focus-visible</code> plugin to apply focus styles only when keyboard navigation is used
Attempts:
2 left
💡 Hint

Think about focus styles that help keyboard users without distracting mouse users.

Practice

(1/5)
1. What is the main role of PostCSS in a SASS with PostCSS pipeline?
easy
A. To compile SASS code into CSS
B. To process compiled CSS and add browser prefixes automatically
C. To write variables and nesting in styles
D. To minify JavaScript files

Solution

  1. Step 1: Understand the role of SASS

    SASS is a preprocessor that lets you write CSS with variables and nesting, but it does not add browser prefixes.
  2. Step 2: Understand the role of PostCSS

    PostCSS processes the compiled CSS to add features like browser prefixes automatically, improving browser compatibility.
  3. Final Answer:

    To process compiled CSS and add browser prefixes automatically -> Option B
  4. Quick Check:

    PostCSS adds prefixes after SASS compiles CSS [OK]
Hint: PostCSS works on CSS output, not on SASS source [OK]
Common Mistakes:
  • Confusing SASS compilation with PostCSS processing
  • Thinking PostCSS compiles SASS
  • Assuming PostCSS writes variables
2. Which of the following is the correct order to use SASS and PostCSS in a build pipeline?
easy
A. Compile SASS first, then run PostCSS
B. Only run SASS, PostCSS is optional
C. Run both simultaneously
D. Run PostCSS first, then compile SASS

Solution

  1. Step 1: Identify the output of SASS

    SASS compiles .scss files into plain CSS files.
  2. Step 2: Understand PostCSS input requirements

    PostCSS works on CSS files, so it must run after SASS compilation.
  3. Final Answer:

    Compile SASS first, then run PostCSS -> Option A
  4. Quick Check:

    SASS compiles, PostCSS processes CSS [OK]
Hint: Compile SASS before PostCSS to process CSS output [OK]
Common Mistakes:
  • Running PostCSS before SASS compilation
  • Trying to run both at the same time
  • Skipping PostCSS thinking it's unnecessary
3. Given this SASS code and PostCSS with autoprefixer, what will be the final CSS output?
$color: blue;
.button {
  color: $color;
  display: flex;
}
medium
A. .button { color: blue; display: -webkit-box; display: -ms-flexbox; display: flex; }
B. .button { color: blue; display: flex; }
C. .button { color: $color; display: flex; }
D. .button { color: blue; display: block; }

Solution

  1. Step 1: Compile SASS variables and nesting

    The variable $color is replaced with blue, so color: blue; is output.
  2. Step 2: PostCSS autoprefixer adds vendor prefixes

    For display: flex;, autoprefixer adds -webkit-box and -ms-flexbox prefixes for browser support.
  3. Final Answer:

    .button { color: blue; display: -webkit-box; display: -ms-flexbox; display: flex; } -> Option A
  4. Quick Check:

    SASS compiles variables, PostCSS adds prefixes [OK]
Hint: SASS compiles variables; PostCSS adds prefixes like -webkit- [OK]
Common Mistakes:
  • Leaving SASS variables uncompiled
  • Ignoring vendor prefixes added by PostCSS
  • Replacing flex with block incorrectly
4. You wrote this SASS code but your PostCSS autoprefixer is not adding prefixes. What is the likely problem?
$main-color: red;
.container {
  color: $main-color;
  display: flex;
}
medium
A. PostCSS does not support autoprefixer
B. You used wrong variable syntax in SASS
C. You forgot to compile SASS before running PostCSS
D. You need to write prefixes manually in SASS

Solution

  1. Step 1: Check SASS compilation step

    If SASS is not compiled first, PostCSS receives raw SASS code and cannot add prefixes.
  2. Step 2: Confirm PostCSS autoprefixer usage

    PostCSS autoprefixer works on CSS, so it requires compiled CSS input.
  3. Final Answer:

    You forgot to compile SASS before running PostCSS -> Option C
  4. Quick Check:

    Compile SASS before PostCSS for prefixes [OK]
Hint: Always compile SASS before PostCSS to enable prefixing [OK]
Common Mistakes:
  • Running PostCSS on uncompiled SASS
  • Assuming autoprefixer works on SASS syntax
  • Thinking prefixes must be written manually
5. You want to create a responsive button style using SASS variables and PostCSS autoprefixer. Which approach correctly combines both tools?
// SASS variables
$btn-color: green;

// SASS nested styles
.button {
  color: $btn-color;
  display: flex;
  &:hover {
    color: darkgreen;
  }
}

// PostCSS autoprefixer runs after SASS compilation
hard
A. Use only PostCSS autoprefixer without SASS for variables
B. Write CSS with prefixes manually, then run SASS compiler
C. Run PostCSS autoprefixer on SASS files before compiling
D. Write SASS with variables and nesting, compile it, then run PostCSS autoprefixer to add prefixes

Solution

  1. Step 1: Use SASS for variables and nesting

    SASS lets you write variables and nested styles for cleaner CSS.
  2. Step 2: Compile SASS to CSS, then run PostCSS autoprefixer

    PostCSS autoprefixer adds vendor prefixes after SASS compilation for browser support.
  3. Final Answer:

    Write SASS with variables and nesting, compile it, then run PostCSS autoprefixer to add prefixes -> Option D
  4. Quick Check:

    SASS for structure, PostCSS for prefixes [OK]
Hint: Write SASS first, then autoprefix CSS with PostCSS [OK]
Common Mistakes:
  • Running autoprefixer before SASS compilation
  • Writing prefixes manually instead of using PostCSS
  • Skipping SASS variables and nesting