Last active
July 2, 2024 01:54
-
-
Save spasma/55125865bd42a0db6f254c2c57a2ae4f to your computer and use it in GitHub Desktop.
Migrate Angular project from CSS to SCSS (Sass) [Also for Angular Material Projects]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Please Backup your project first!!!!!!!! | |
# run this in your project root folder | |
# rename all your src files | |
cd src | |
find . -name "*.css" -exec bash -c 'mv "$1" "${1%.css}".scss' - '{}' \; | |
cd .. | |
# change angular cli config in angular.json | |
sed -i -e 's/styles.css/styles.scss/g' angular.json | |
# Change all ts-files (change .css to .scss) in @Module styleUrls | |
find ./src -name "*.ts" -exec sed -i -e 's/\(.*styleUrls.*\)\.css\(.*\)/\1\.scss\2/g' {} + | |
find ./src -name "*.ts-e" -exec bash -c 'rm "$1"' - '{}' \; | |
# Angular <6.1 (running on 8 doesn't break anything) | |
ng set defaults.styleExt scss | |
# Angular 6+ version of the above one | |
ng config schematics.@schematics/angular:component.styleext scss | |
# Add node-sass npm module | |
npm install node-sass --save-dev | |
# Everything should work now! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment