Reputation: 1334
I have a react application, which was created using create-react-app. I included react-bootstrap in my project and when I start/build application, bootstrap css file imported. How can I change this css with my custom one? I am aware that I can just add new css in index.js, but won't both css files be imported in that case?
Since I am creating a custom bootstrap theme, I would prefer if default bootstrap css file is not imported, as I am building new css file from my custom scss file and bootstrap scss files.
My package.json:
{
"name": "reading-manager-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"bootstrap": "^3.3.7",
"chart.js": "^2.7.2",
"react": "^16.4.2",
"react-bootstrap": "^0.32.1",
"react-chartjs-2": "^2.7.4",
"react-dom": "^16.4.2",
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"react-scripts": "1.1.4",
"redux": "^4.0.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
npm start generates:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
How do I go about changing these imports to my own compiled ones? I would prefer not to use remote repositories.
Upvotes: 1
Views: 632
Reputation: 222840
It's unlikely that npm start
will generate <link>
tags because react-scripts
doesn't contain a mechanism to inject them and resolve packages to CDN URLs automatically.
create-react-app
configures Webpack to support CSS loaders, the boilerplate already contains:
import './App.css';
Any CSS can be imported like that:
import 'bootstrap/dist/css/bootstrap.css';
Upvotes: 2