Angular 6 load css folders in angular.json

ε祈祈猫儿з 提交于 2019-12-04 19:33:57

问题


I am trying to convert my html template into angular app. I have a css folder called plugins and img folder.

When I am adding :

 "styles": [
          "src/assets/plugins/listtyicons/style.css",
          "src/assets/plugins/jquery-ui/jquery-ui.min.css",
          "src/assets/plugins/bootstrap/css/bootstrap.min.css",
          "src/assets/plugins/plugins/isotope/isotope.min.css",
          "src/styles.css"

        ]

this code in angular.json file I am getting error when trying to start angular app. I have put my plugin folder inside assets folder. I am getting this error:

 ERROR in multi ./src/assets/plugins/listtyicons/style.css 
./src/assets/plugins/jquery-ui/jquery-ui.min.css ./src/assets/plugins/bootstrap/css/bootstrap.min.css ./src/assets/plugins/plugins/isotope/isotope.min.css ./src/styles.css
Module not found: Error: Can't resolve 
'/Users/nilay/angular/bes/src/assets/plugins/plugins/isotope/isotope.min.css' 
in '/Users/nilay/angular/bes'

I don't know why am I getting this error.


回答1:


In angular 6 you have to add only in src/style.css (instead angular.json):

@import "assets/plugins/listtyicons/style.css";
@import "assets/plugins/jquery-ui/jquery-ui.min.css";
@import "assets/plugins/bootstrap/css/bootstrap.min.css";
@import  "assets/plugins/plugins/isotope/isotope.min.css";

And in angular.json

"styles": [
          "src/styles.css"
        ]


来源:https://stackoverflow.com/questions/50617488/angular-6-load-css-folders-in-angular-json

标签

工具导航Map