What is SASS and why do we use it in web development?
SASS is a tool that helps write CSS easier and faster. It adds features like variables and nesting, making stylesheets simpler to manage and change.
Click to reveal answer
beginner
What command installs dart-sass using npm?
You run npm install -D sass to add dart-sass as a development tool in your project.
Click to reveal answer
beginner
How do you compile a SASS file to CSS using dart-sass in the terminal?
Use npx sass input.scss output.css to turn your SASS file into a CSS file you can use in your website.
Click to reveal answer
intermediate
Why is it helpful to add a watch command when working with SASS?
The watch command automatically updates your CSS whenever you save changes in your SASS files, saving time and avoiding manual compiling.
Click to reveal answer
intermediate
What is the difference between installing SASS globally and locally with npm?
Global install lets you use SASS commands anywhere on your computer. Local install keeps SASS inside your project, making it easier to manage versions and share with others.
Click to reveal answer
Which npm command installs dart-sass as a development dependency?
Anpm install sass -g
Bnpm install -D sass
Cnpm install sass
Dnpm update sass
✗ Incorrect
The -D flag installs sass as a development dependency locally in your project.
What does the command npx sass input.scss output.css do?
AInstalls SASS globally
BCreates a new SASS project
CRuns SASS to convert input.scss into output.css
DDeletes output.css
✗ Incorrect
This command compiles the SASS file into a CSS file you can use in your website.
Why might you use the watch option with SASS?
ATo automatically recompile CSS when SASS files change
BTo install SASS globally
CTo uninstall SASS
DTo create a new SASS file
✗ Incorrect
Watching saves time by updating CSS automatically when you save changes in SASS files.
Which of these is NOT a benefit of using SASS?
AAutomatically fixes HTML errors
BNesting selectors for clarity
CVariables for colors and sizes
DMixins to reuse code
✗ Incorrect
SASS helps with CSS, but it does not fix HTML errors.
What is the main reason to install SASS locally in a project?
ATo speed up your internet connection
BTo use SASS commands anywhere on your computer
CTo automatically update npm
DTo keep project dependencies organized and consistent
✗ Incorrect
Local install keeps tools tied to the project, making sharing and version control easier.
Explain the steps to set up SASS in a new web project using npm and dart-sass.
Think about installing, compiling, and automating.
You got /4 concepts.
Describe why using SASS can improve your CSS workflow and how the watch command helps.
Focus on benefits and automation.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of using npm when setting up SASS with Dart SASS?
easy
A. To write SASS code directly in the terminal
B. To run a web server for SASS files
C. To convert CSS files into SASS files
D. To install the Dart SASS compiler package
Solution
Step 1: Understand npm's role in SASS setup
npm is a package manager used to install tools like Dart SASS compiler.
Step 2: Identify what npm installs for SASS
npm installs the Dart SASS compiler so you can compile SASS files to CSS.
Final Answer:
To install the Dart SASS compiler package -> Option D
Quick Check:
npm installs packages = B [OK]
Hint: npm installs tools like Dart SASS compiler [OK]
Common Mistakes:
Thinking npm runs SASS code directly
Confusing CSS to SASS conversion
Assuming npm runs a web server
2. Which command correctly installs Dart SASS using npm?
easy
A. npm install -g sass
B. npm sass install
C. npm get sass
D. npm run sass
Solution
Step 1: Recall npm install syntax
The correct npm command to install a package globally is npm install -g <package-name>.
Step 2: Match the command to Dart SASS
For Dart SASS, the package name is sass, so the command is npm install -g sass.
Final Answer:
npm install -g sass -> Option A
Quick Check:
npm install -g package = A [OK]
Hint: Use 'npm install -g package' to install globally [OK]
Common Mistakes:
Using 'npm sass install' which is invalid syntax
Confusing 'npm get' with install
Trying to run sass with 'npm run' without setup
3. What will happen if you run the command sass --watch styles.scss:styles.css in your terminal?
medium
A. It compiles styles.scss to styles.css once and exits
B. It watches styles.scss and updates styles.css on changes
C. It watches styles.css and updates styles.scss on changes
D. It throws an error because of wrong syntax
Solution
Step 1: Understand the --watch flag
The --watch flag tells SASS to monitor the source file for changes continuously.
Step 2: Analyze the command's file mapping
styles.scss:styles.css means compile styles.scss into styles.css whenever styles.scss changes.
Final Answer:
It watches styles.scss and updates styles.css on changes -> Option B
Quick Check:
--watch updates CSS on SASS changes = C [OK]
Hint: Use --watch to auto-update CSS on SASS file changes [OK]
Common Mistakes:
Thinking it compiles only once
Confusing source and output files
Assuming syntax error in correct command
4. You ran npm install -g sass but get a 'command not found' error when typing sass. What is the likely cause?
medium
A. You need to restart the terminal or add npm global bin to PATH
B. npm did not install sass globally
C. The sass package is deprecated and removed
D. You must run sass with 'node sass' command
Solution
Step 1: Understand global install effects
Installing globally adds sass to a folder that must be in your system PATH to run from terminal.
Step 2: Identify common PATH issues
If PATH is not updated or terminal not restarted, the system won't find the sass command.
Final Answer:
You need to restart the terminal or add npm global bin to PATH -> Option A
Quick Check:
PATH update needed after global install = A [OK]
Hint: Restart terminal or update PATH after global npm install [OK]
Common Mistakes:
Assuming sass package is deprecated
Trying to run sass with 'node sass'
Thinking npm install failed without checking PATH
5. You want to automatically compile all SASS files in the src/sass folder into CSS files in dist/css folder whenever you save changes. Which command should you use?
hard
A. sass watch src/sass dist/css
B. sass src/sass dist/css --watch
C. sass --watch src/sass:dist/css
D. sass --watch src/sass/*.scss dist/css/*.css
Solution
Step 1: Understand folder watching syntax
The syntax sass --watch input-folder:output-folder watches all SASS files in input-folder and compiles to output-folder.
Step 2: Evaluate each option
sass --watch src/sass:dist/css uses correct syntax. Options A, B, and C have wrong order or invalid syntax.
Final Answer:
sass --watch src/sass:dist/css -> Option C
Quick Check:
Folder watch uses --watch input:output = D [OK]
Hint: Use --watch with folder paths separated by colon [OK]
Common Mistakes:
Using spaces instead of colon between folders
Trying to watch files with wildcards incorrectly
Using 'sass watch' instead of 'sass --watch'
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.