Ad

Injecting Dependencies In Vs Package.json

- 1 answer

I have bootstrap dependency inside the "head" tag of html file which references physically added library files that i downloaded.

I also have a bootstrap dependency inside package.json added via npm.

I only need the dependencies in one place right? For example i can remove from "head" tag and keep inside package.json?

Ad

Answer

Adding dependencies inside your package.json does not means that dependencies are automatically used by your bundle: you have to import stuff inside your JS/SASS to make this happen.

You didn't said what is you bootstrap dependency, but let say is the default Bootstrap package. You have to do:

import "bootstrap/dist/css/bootstrap.css"

To have the Bootstrap CSS bundled in your application. The same for the JavaScript source... but I don't think you really want to have Bootstrap JS in a React app. Look at react-bootstrap instead.

Ad
source: stackoverflow.com
Ad