Bird
Raised Fist0
SASSmarkup~20 mins

Index files for folder imports in SASS - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Sass Index Import Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate
2:00remaining
What is the output of this Sass import resolution?

Given a folder styles/ containing _index.scss and _buttons.scss, what file(s) will be imported by @use 'styles';?

SASS
@use 'styles';
ABoth _index.scss and _buttons.scss are imported
BNo files are imported, error occurs
COnly _buttons.scss is imported
DOnly _index.scss is imported
Attempts:
2 left
💡 Hint

Think about how Sass resolves folder imports with index files.

🧠 Conceptual
intermediate
2:00remaining
Why use an index file for folder imports in Sass?

What is the main benefit of having an _index.scss file inside a folder for Sass imports?

AIt allows importing multiple files with a single import statement
BIt prevents any files in the folder from being imported
CIt automatically compiles all Sass files in the folder separately
DIt disables Sass linting for the folder
Attempts:
2 left
💡 Hint

Consider how you can simplify import statements.

📝 Syntax
advanced
2:00remaining
Which option correctly imports all Sass partials in a folder using an index file?

Given a folder components/ with _index.scss, _header.scss, and _footer.scss, which _index.scss content correctly imports all partials?

A
@use './header';
@use './footer';
B
@import 'header';
@import 'footer';
C
@use 'components/header';
@use 'components/footer';
D
@use 'header';
@use 'footer';
Attempts:
2 left
💡 Hint

Remember relative paths inside index files and modern Sass import syntax.

❓ optimization
advanced
2:00remaining
How does using an index file improve Sass build performance?

What is a key reason that using an _index.scss file for folder imports can optimize Sass compilation?

AIt disables source maps for faster builds
BIt compiles each partial into a separate CSS file automatically
CIt reduces the number of import statements and dependency checks
DIt caches all partials in memory permanently
Attempts:
2 left
💡 Hint

Think about how Sass processes imports and dependencies.

🔧 Debug
expert
2:00remaining
Why does this Sass import fail when using an index file?

Given this folder structure:

components/
  _index.scss
  _button.scss
  _card.scss

And _index.scss content:

@use 'button';
@use 'card';

Why does @use 'components'; in main.scss cause an error?

ABecause Sass does not support @use inside index files
BBecause @use inside _index.scss needs relative paths like './button' and './card'
CBecause _index.scss must be named _components.scss to work
DBecause @use cannot import partials starting with underscore
Attempts:
2 left
💡 Hint

Check how paths are resolved inside index files.

Practice

(1/5)
1. What is the main purpose of an _index.scss file in a Sass folder?
easy
A. To store variables only for that folder
B. To compile Sass files into CSS automatically
C. To group and import all Sass partials in that folder with a single import
D. To define mixins that cannot be imported

Solution

  1. Step 1: Understand the role of _index.scss

    The _index.scss file acts as a central place to import all other Sass partials in the folder.
  2. Step 2: Recognize the benefit

    Importing the folder once in your main Sass file will include all styles from the partials via the _index.scss file.
  3. Final Answer:

    To group and import all Sass partials in that folder with a single import -> Option C
  4. Quick Check:

    Index file groups partials = A [OK]
Hint: Index files bundle folder imports into one [OK]
Common Mistakes:
  • Thinking _index.scss compiles CSS directly
  • Confusing index file with variable-only files
  • Assuming mixins can't be imported via index
2. Which of the following is the correct way to import all Sass files from a folder named components using an index file?
easy
A. @import 'components';
B. @import 'components/index.scss';
C. @import 'components/*';
D. @import 'components/index';

Solution

  1. Step 1: Recall Sass folder import rules

    When importing a folder, Sass automatically looks for an _index.scss file inside it.
  2. Step 2: Choose the correct import syntax

    Using @import 'components'; imports the _index.scss file inside the components folder.
  3. Final Answer:

    @import 'components'; -> Option A
  4. Quick Check:

    Folder import auto-loads _index.scss = B [OK]
Hint: Import folder name only to load _index.scss [OK]
Common Mistakes:
  • Trying to import with wildcard (*) which Sass doesn't support
  • Including the underscore and extension explicitly
  • Using 'index' instead of '_index'
3. Given a folder buttons with _primary.scss and _secondary.scss, and an _index.scss file importing both, what will be the output CSS if you import buttons folder in your main Sass file?
medium
A. Only styles from _primary.scss
B. Only styles from _index.scss without others
C. No styles because folder import is invalid
D. CSS styles from both _primary.scss and _secondary.scss combined

Solution

  1. Step 1: Understand _index.scss role

    The _index.scss imports _primary.scss and _secondary.scss, so it acts as a bundle.
  2. Step 2: Importing the folder includes all partials

    Importing the buttons folder loads _index.scss, which imports both partials, combining their styles.
  3. Final Answer:

    CSS styles from both _primary.scss and _secondary.scss combined -> Option D
  4. Quick Check:

    Folder import loads all partials via index = D [OK]
Hint: Index file imports all partials, so folder import includes all [OK]
Common Mistakes:
  • Assuming only index file styles appear
  • Thinking folder import is invalid syntax
  • Believing only one partial loads automatically
4. You wrote @import 'cards'; in your main Sass file, but styles from _card.scss inside the cards folder are not applied. What is the most likely cause?
medium
A. You forgot to add _card.scss extension in import
B. The _index.scss file inside cards does not import _card.scss
C. Sass does not support folder imports
D. The _card.scss file is empty

Solution

  1. Step 1: Check folder import mechanism

    Importing cards loads _index.scss inside it, which must import all partials.
  2. Step 2: Identify missing import in _index.scss

    If _card.scss is not imported in _index.scss, its styles won't be included.
  3. Final Answer:

    The _index.scss file inside cards does not import _card.scss -> Option B
  4. Quick Check:

    Missing partial import in index = A [OK]
Hint: Ensure index file imports all partials in folder [OK]
Common Mistakes:
  • Expecting Sass to auto-import all partials without index
  • Adding extensions in folder import statement
  • Assuming empty partials cause import failure
5. You want to organize your Sass project with folders for buttons and forms, each having multiple partials. How should you structure your imports in the main Sass file to keep it clean and efficient?
hard
A. Create _index.scss in each folder importing all partials, then import folders once in main file
B. Import every partial individually in the main Sass file
C. Use wildcard imports like @import 'buttons/*'; and @import 'forms/*';
D. Combine all partials into one big file and import only that

Solution

  1. Step 1: Use index files for folder organization

    Creating _index.scss in each folder lets you import all partials there once.
  2. Step 2: Import folders in main Sass file

    Importing the folder name loads the _index.scss, keeping main file clean and efficient.
  3. Final Answer:

    Create _index.scss in each folder importing all partials, then import folders once in main file -> Option A
  4. Quick Check:

    Index files + folder imports = C [OK]
Hint: Use index files per folder, import folders once in main [OK]
Common Mistakes:
  • Importing every partial individually causing clutter
  • Trying unsupported wildcard imports
  • Merging all partials losing modularity
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard