简体   繁体   中英

Angular 4 CLI ng build no converting scss to css

When I run ng build , the generated dist folder doesn't convert scss files to css .

I have a main.scss in my assets folder and .angular-cli.json has:

"styles": [
        "assets/scss/main.scss"
 ],

.....

"styleExt": "scss",

You can do ng new myApp --style=scss

Then Angular CLI will create any new component with scss for you...

You also need to use node-sass , install it like this:

npm install node-sass --save-dev

You also need to change styleExt in angular-cli.json to sass ...

and use sassCompiler in angular-cli-build.js like this:

sassCompiler: {
    includePaths: [
      'src/app/scss' //here add scss
    ]
 }

and you should be good to go!

for more info visit here .

The content of the assets folder isn't changed by angular. Move it to the /app folder and change .angular-cli.json to.

"styles": [
   "main.scss"
 ],

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM