Home > Web Front-end > CSS Tutorial > How to Migrate from CSS to SCSS in Angular CLI?

How to Migrate from CSS to SCSS in Angular CLI?

Linda Hamilton
Release: 2024-12-12 12:38:16
Original
658 people have browsed it

How to Migrate from CSS to SCSS in Angular CLI?

Angular CLI: Converting from CSS to SCSS

When transitioning an Angular project from CSS to SCSS, you may encounter an error stating:

styles.bundle.js:33Uncaught Error: Module build failed: Error: ENOENT:
no such file or directory, open
'/Users/Egen/Code/angular/src/styles.css'
Copy after login

For Existing Projects (Angular 6)

  1. Update the default style extension to "scss":

    • Manually edit .angular-cli.json or angular.json (Angular 6 ):

      {
      "defaults": {
        "styleExt": "scss"
      }
      }
      Copy after login
    • Or run:

      ng config defaults.styleExt=scss
      Copy after login
  2. Rename existing .css files to .scss.
  3. Update apps[0].styles in angular.json to include the .scss extensions.
  4. Update component styleUrls to reflect the new file names.

For Future Projects

  1. Create a new project using:

    ng new your-project-name --style=scss
    Copy after login
  2. Set the global default style extension:

    ng config --global defaults.styleExt=scss
    Copy after login

The above is the detailed content of How to Migrate from CSS to SCSS in Angular CLI?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template