Mime type error when adding a CSS file to Angular

后端 未结 9 833
野的像风
野的像风 2020-12-20 11:36

I\'m trying to build a static site using Angular. What I want is to have some global css/js/image files to be added to the index.html

This is my code in

9条回答
  •  情歌与酒
    2020-12-20 11:51

    Solution 1 (with Bootstrap installed)

    All you need to do is:

    1) Go to .angular-cli.json under the root directory of your angular app.

    2) Modify the styles array to include bootstrap before styles.css

    "styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "styles.css"
      ],
    

    Note: the path to bootstrap is relative to /src/index.html that's why you need "../" before node_modules.

    3) Exit the current session of ng serve and start it again.

    Here is an Awesome tutoral

    Solution 2 (with Bootstrap referenced)

    All you need to is:

    1) Go to styles.css under the root directory of your angular app.

    2) Add this line at the top:

    @import url('https://unpkg.com/bootstrap@3.3.7/dist/css/bootstrap.min.css');
    

    Here is Angular docs

提交回复
热议问题