Incorrect order of CSS in build version
See original GitHub issueIs this a bug report?
Yes
Environment
npx create-react-app --info
prints empty result for some reason.
Steps to Reproduce
Using CRA 3.0.1.
create-react-app style_test
npm i bootstrap@3.3.7 --save
- In
index.js
import two CSS files - first, a reset CSS, second, the bootstrap CSS. - Run dev server and production builds and compare results.
Expected Behavior
Both dev server and production builds should display text using bootstrap CSS.
Actual Behavior
Dev server works as expected, but production build contains two CSS chunks, one with bootstrap code and another with reset CSS, loaded in wrong order (bootstrap first). As a result, in production version text is not styled.
Bootstrap (and only bootstrap) appears in 2.*.chunk.css
, while reset CSS and all my sass styles end up in main.*.chunk.css
. What is the benefit of using two chunks, anyway? Just faster load times due to parallel loading of both scripts?
Reproducible Demo
Issue Analytics
- State:
- Created 4 years ago
- Reactions:34
- Comments:14 (1 by maintainers)
Top Results From Across the Web
create-react-app npm run build wrong css order - Stack Overflow
In development this works just fine, but using the compiled css after running npm run build makes the responsive styling messed up. After...
Read more >Optimizing Performance - React
To create a production build, make sure that you add these transforms (the order matters): The envify transform ensures the right build environment...
Read more >react-app-rewired - npm
1) Install react-app-rewired · 2) Create a config-overrides.js file in the root directory · 3) 'Flip' the existing calls to react-scripts in npm ......
Read more >How To Set Up a React Project with Create React App
Then you will run the build script to create a minified version. ... App.css App.js App.test.js index.css index.js logo.svg serviceWorker.js ...
Read more >How to tell ReactJS to build project in Production mode
Your JavaScript and CSS files will be inside the build/static directory. A number of .js files are generated and placed inside the ...
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 FreeTop 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
Top GitHub Comments
I was able to resolve this by importing my css files from within my sass entrypoint file.
main.scss
It seems like this will preserve the order correctly
Wow… I faced this issue in create-react-app 4 …
The Dev server css order changed to in production build,
For me css of a node_module is taking preceding over my css.
Is there any possible solution that cra provides ?