"import 'bootstrap/dist/css/bootstrap.min.css';" doesn't work in the program
See original GitHub issueI tried using import 'bootstrap/dist/css/bootstrap.min.css to import Bootstrap, but this code doesn’t work as,

Prerequisites
- Using yarn
- Using node 10.x
- Using an up-to-date
masterbranch - Using latest version of devtools. See wiki for howto update
- Link to stacktrace in a Gist (for bugs)
- For issue in production release, devtools output of
DEBUG_PROD=true yarn build && yarn start - Tried solutions mentioned in #400
Note for using latest version of devtools: The command for updating extensions version cannot work on Windows PowerShell, which need to be confirmed.
Note for link to stacktrace in a Gist (for bugs): I am sorry for that, as a beginner, I don’t know how to do that.
Expected Behavior
import 'bootstrap/dist/css/bootstrap.min.css can work normally as,

Current Behavior
import 'bootstrap/dist/css/bootstrap.min.css seemed not to take effect, and it shows as,

Possible Solution
Steps to Reproduce (for bugs)
-
Git clone the electron-react-boilerplate;
-
Install Bootstrap using
yarn add react-bootstrap bootstrap; -
Change the code of HomePage.tsx as,
import React from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';
export default function HomePage() {
return (
<div className="container-fluid">
<div className="row">
<div className="col-3 bg-light left-panel">
<h1>this is the left</h1>
</div>
<div className="col-9 bg-primary right-panel">
<h1>this is the right</h1>
</div>
</div>
</div>
);
}
- Run as
yarn dev
Context
This issue make me unable to use import to use import .cssfile.
Almost not.
Your Environment
- Node version : v12.18.2
- Version or Branch used : 1.2.0
- Operating System and version : Windows 10
- Link to your project :
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (2 by maintainers)
Top Results From Across the Web
reactjs - Module not found: Can't resolve 'bootstrap/dist/css ...
Looks like after installing the import isn't needed for it to load bootstrap styles correctly. So if you are having trouble with this,...
Read more >Module not found: Can't resolve bootstrap/dist/css/bootstrap ...
To solve the error "Module not found: Error: Can't resolve 'bootstrap/dist/css/bootstrap.min.css'", make sure to install the bootstrap package by opening your ...
Read more >Getting started - Bootstrap
Regenerates the /dist/ directory with compiled and minified CSS and JavaScript files. ... Respond.js doesn't work with CSS that's referenced via @import ....
Read more >Using Bootstrap with React: Tutorial with examples
How to troubleshoot Bootstrap not working in React ... Bootstrap CSS import "bootstrap/dist/css/bootstrap.min.css"; // Bootstrap Bundle JS ...
Read more >can't resolve 'bootstrap/dist/css/bootstrap.css' - You.com
Run npm install command again. · Try delete the entire npm_modules folder and run npm install . · Try reinstalling bootstrap. · Make...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The solution is to import bootstrap in
app.global.cssHere’s an example of an app that’s using react-bootstrap and importing bootstrap’s SASS.
@songyuc
Well I mainly just use bootstrap for its layouts
bootstrap.grid.css, everything else is a bunch of custom css. I know it’s bad, but for my needs its fineAlso, here’s what I figured out about the css loading:
In
configs/webpack.config.renderer.dev.babel.js(andconfigs/webpack.config.renderer.prod.babel.js) there are some css loading options such as:(Note the comments)
so anything marked as .global.css will be loaded as is. and otherwise it generates a unique name to avoid collisions:
localIdentName: '[name]__[local]__[hash:base64:5]',so you can have the best of both worlds 😃What I did is copied the bootstrap min css into my actual project folder, and renamed it to end in
.global.css, and now it gets loaded as is.