Discover how a simple directive can save you hours of fixing broken style imports!
Why @forward directive for re-exporting in SASS? - Purpose & Use Cases
Imagine you have many small Sass files with colors, buttons, and layouts. You want to use them all in one main file by copying and pasting each import everywhere.
Copying imports everywhere is slow and messy. If you rename or move a file, you must update every import manually. It's easy to forget and cause errors.
The @forward directive lets you gather and re-export styles from many files in one place. Then you import just that one file, keeping your code clean and easy to manage.
@import 'colors'; @import 'buttons'; @import 'layouts';
// _all.scss @forward 'colors'; @forward 'buttons'; @forward 'layouts'; // main.scss @use 'all';
You can organize styles into small files and share them easily without repeating imports everywhere.
A big website with many style parts can keep each part in its own file and combine them cleanly for faster updates and fewer mistakes.
Manually importing many files everywhere is error-prone and hard to maintain.
@forward gathers and re-exports styles from multiple files in one place.
This keeps your Sass code organized, clean, and easy to update.