Ship craco (CRA config override) adapter in `cypress/react`
See original GitHub issueI use craco for react, so I can use Less with create-react-app
It replaces react-scripts start
with craco start
, so that the Less gets bundled to css.
When using cypress normally, it’s all good, because I start up the web server, and then it just gets served from there.
With the component runner however, it just renders the components directly. How can i make the styles work? If I mount a component that directly imports the App.less
file, it obviously makes no difference.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Create React App Configuration Override with Craco. What is ...
In this video, we'll update babel in CRA. How do I add Babel config in React app? - it's not a problem.Create React...
Read more >Custom Templates - Create React App
Custom Templates enable you to select a template to create your project from, while still retaining all of the features of Create React...
Read more >create-react-app config override for build - Stack Overflow
Then I thought: "well, if create-react-app works, maybe I could use CRA and just override things I don't care about?". I installed craco...
Read more >Migrating from Create React App - Next.js
js optimizes images on-demand, as users request them. Your build times aren't increased, whether shipping 10 images or 10 million images. import Image...
Read more >Unit testing React components in Cypress without CRA and ...
I had to go through some hassle to get that working with a custom webpack configuration, but it's finally working, and here is...
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
Right, this makes perfect sense - using the
react-scripts
plugin to inject the dev server grabs the unconfigured webpack config from CRA - the whole point of craco is to override that.I looked into this and learned I can use the craco webpack API, specifically
createWebpackDevConfig
, to get the modified config.I wrote this code and was able to get the less styling to work with Cypress. The following is in
cypress/plugins/index.js
.I think we can justify bundling a craco plugin with
@cypress/react
. I will work on shipping this. For now, you could use the above snippet.Please let me know if this is working for you.
It works, thank you!