2

Trying to add some global scss file to the project but it is not compiling.

all other scss files of the components are compiling correctly.

eg. app.component.scss is working

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})

the angular-cli.json file looks like

"apps": [{
        .
        .
        "styles": [
                    "styles.scss"
                  ],
        .
        .
    }],

 "defaults": {
              "styleExt": "scss",
               .
               .
              }

the styles.scss is not compiling which looks like

body{
   background:#f00;
}

i have already tried these but still not working

angular-cli how to add global styles?

angular-cli how to add sass and or bootstrap?

https://github.com/angular/angular-cli/issues/1787

https://github.com/angular/angular-cli/pull/1492

https://github.com/angular/angular-cli/issues/1459

angular-cli version is

1.0.0-beta.24

Community
  • 1
  • 1
shah
  • 1,163
  • 2
  • 19
  • 40
  • I have the same setup that you described and it's working for me, so I think there must be something else.. do you have a project link? – adriancarriger Dec 26 '16 at 23:31
  • don't know something went wrong.and don't have any external link working on local PC. – shah Dec 26 '16 at 23:37
  • Sorry, if you have an error message that could be helpful.. also you might try posting your project to [Github](https://github.com/) and sharing it here. Also, you might try starting a completely new project by running `ng new my-project --style=scss` and see if you still have the same issue – adriancarriger Dec 26 '16 at 23:39
  • there is also styles.css in src/styles.css after deleting this show this error `ERROR in ./src/styles.css Module build failed: ModuleBuildError: Module build failed: Error: ENOENT: no such file or directory, open 'PROJECT_PATH\src\styles.css'` – shah Dec 26 '16 at 23:42
  • For some reason the CLI is looking for the `.css` file instead of the `.scss`. It would probably be helpful to see the entire `angular-cli.json` – adriancarriger Dec 26 '16 at 23:45
  • but `styles.css` is not mention in `angular-cli.json` – shah Dec 26 '16 at 23:50
  • I agree that it's pretty strange. Perhaps another file is asking for it? I would try running `ng new my-project --style=scss` and see if you still get the error. This command will setup everything and you should never see a file named `styles.css` – adriancarriger Dec 26 '16 at 23:54
  • 1
    If you make changes to `angular-cli.json` you must restart `ng serve` as the configuration information is only read at startup, so changes are not picked up until the process is restarted. Just mentioning this as it might be part of this issue. – Brocco Dec 27 '16 at 04:20
  • Yes man! you are right after restarting it is working now. Thank you so much. – shah Dec 27 '16 at 08:13

0 Answers0