Categories
Angular Answers

How to add Bootstrap to an angular-cli project?

Spread the love

Sometimes, we want to add Bootstrap to an angular-cli project.

In this article we’ll look at how to add Bootstrap to an angular-cli project.

How to add Bootstrap to an angular-cli project?

To add Bootstrap to an angular-cli project, we can install the bootstrap package and then add the Bootstrap script and CSS paths into angular.json.

We run

npm install bootstrap

to install bootstrap.

Then we write

//...
{
  "scripts": ["./node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"],
  //...
  "styles": [
    "styles.css",
    "./node_modules/bootstrap/dist/css/bootstrap.min.css"
  ]
}
//...

to add the Bootstrap scripts and styles paths into angular.json.

Then we restart ng serve so the changes in angular.json will be picked up.

Conclusion

To add Bootstrap to an angular-cli project, we can install the bootstrap package and then add the Bootstrap script and CSS paths into angular.json.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *