I'm using angular2-webpack-starter to build my project and I want to use bootstrap as well.
I install ng2-bootstrap as npm install ng2-bootstrap --save. Since the ng2-bootstrap only has some directives and it requires the "real" .css file of bootstrap to style it (but its author seems to assume we have had it), so I install bootstrap as npm install bootstrap --save.
Now, my question is how to import the "real" bootstrap .css file to my project, so that ng2-bootstrap can use it.
I tried several ways:
copy the
bootstrap.min.cssfile fromnode_modules/bootstrap/dist/cssfolder to mysrc/assets/cssfolder and add<link href="assets/css/bootstrap.min.css" rel="stylesheet">to myindex.html. This way works but my concern is that thebootstrap.min.cssfile won't be managed bynpmany more. I have to manually update it in future.Another attempt is requiring it from my
app.component.tslikestyles: [ require('./app.style.css'), require('../../node_modules/bootstrap/dist/css/bootstrap.min.css') ],
but it can't be resolved.
- last try is adding
import 'bootstrap';tovendor.browser.tsjust likeimport '@angular/core';in it. But it failed either. It seems that thebootstrapis not a package like@angular2/corethat I can easily import it.
So, my question comes down to how to import/load bootstrap in webpack, so that it can be used by ng2-bootstrap and other components in my project and it can also be upgraded by using npm.
require('../../node_modules/bootstrap/dist/css/bootstrap.min.css')?