2

I'm building a React application and would like to use Bootstrap in it. Therefore I'm using the package bootstrap-react. Bootstrap's CSS has to be integrated in the index.html. Currently I've got this:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">

I would like to use it directly from npm (https://www.npmjs.com/package/bootstrap) but don't know how to reference it. I could copy it via Gulp but is there a better way?

1 Answer 1

4

webpack

If you are using webpack, you can use the style-loader to require() the CSS file directly.

SASS

If you are using SASS, you can install bootstrap-sass and import the file directly from node_modules into your scss file

@import "../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

I've had the most success with these two options. You can probably do the same thing with Less, although Bootstrap just announced they were switching to SASS, so you might want to switch anyway.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.