|
| 1 | +# SCSS to Sass Modules Migration Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | +This document outlines the process and fixes implemented to migrate the SCSS codebase from the deprecated `@import` syntax to the modern Sass module system using `@use` and `@forward`. |
| 5 | + |
| 6 | +## Migration Steps |
| 7 | + |
| 8 | +### 1. Utility Files Conversion |
| 9 | +- Converted `_variables.scss` to use module system |
| 10 | +- Converted `_mixins.scss` to use module system with variables namespace |
| 11 | +- Converted remaining utility files (`_reset.scss`, `_fonts.scss`, etc.) |
| 12 | +- Created `_index.scss` in scss directory to forward all utilities |
| 13 | + |
| 14 | +### 2. Variable and Mixin Access |
| 15 | +- Made private variables public in `_variables.scss` by removing underscore prefixes |
| 16 | +- Updated mixins to use public variable names |
| 17 | +- Established consistent namespace prefixes: `v.` for variables, `m.` for mixins |
| 18 | + |
| 19 | +### 3. Component Files Updates |
| 20 | +- Updated component files to use new module system |
| 21 | +- Fixed namespace conflicts in component files |
| 22 | +- Fixed mixin namespace issues in component files using automated scripts |
| 23 | +- Fixed path issues in nested component files |
| 24 | + |
| 25 | +### 4. Key Fixes Implemented |
| 26 | + |
| 27 | +#### Fix for Mixin Namespaces |
| 28 | +Created and iteratively improved `fix-mixin-namespaces.sh` to automatically add the correct namespace prefix (`m.`) to all mixin calls, including: |
| 29 | +- Basic layout mixins |
| 30 | +- Font-related mixins (`heading-font`, `title-font`, etc.) |
| 31 | +- Responsive design mixins (`media`, `only_ie10_above`, etc.) |
| 32 | +- Utility mixins (`aspect-ratio-box`, `clean-ul`, etc.) |
| 33 | + |
| 34 | +#### Fix for Nested Import Paths |
| 35 | +Created `fix-nested-paths.sh` to automatically correct relative import paths in nested component SCSS files by: |
| 36 | +- Calculating the correct relative path from each file to the `scss` directory |
| 37 | +- Updating `@use` import paths for `variables` and `mixins` |
| 38 | + |
| 39 | +#### Fix for Page Grid Variables |
| 40 | +- Identified conflicts between local and global page grid variables |
| 41 | +- Fixed variable definitions in `page.scss` to use proper local variables |
| 42 | +- Fixed variable references in media queries |
| 43 | + |
| 44 | +## Scripts Created |
| 45 | + |
| 46 | +### fix-mixin-namespaces.sh |
| 47 | +Automatically prefixes mixin calls with the correct namespace (`m.`). |
| 48 | + |
| 49 | +### fix-nested-paths.sh |
| 50 | +Fixes relative import paths in nested component SCSS files. |
| 51 | + |
| 52 | +### fix-duplicate-prefixes.sh |
| 53 | +Fixes duplicate namespace prefixes (e.g., `v.v.`) that occurred during migration. |
| 54 | + |
| 55 | +### fix-page-vars.sh and fix-page-media-queries.sh |
| 56 | +Fix variable references and media queries in the page component. |
| 57 | + |
| 58 | +## Remaining Considerations |
| 59 | +- The build shows deprecation warnings for `@import` rules in component files that could be addressed in a future phase |
| 60 | +- Consider migrating component files from `@import` to `@use`/`@forward` in a separate task |
| 61 | + |
| 62 | +## Benefits of the Migration |
| 63 | +- Modern, more maintainable Sass code |
| 64 | +- Explicit namespaces prevent naming collisions |
| 65 | +- Better encapsulation of variables and mixins |
| 66 | +- Improved build performance through better dependency management |
0 commit comments