Questions tagged [craco]

Craco stands for Create React App Configuration Overrides - an easy and comprehensible configuration layer for create-react-app.

Craco is a mechanism for overriding aspects the standard Create React App configuration without forcing the developer to eject their app from CRA.

It allows you add a single craco.config.js file at the root of your application and thus customise your eslint, babel, postcss, and webpack configurations.

71 questions
15
votes
1 answer

Can't import other project's component in create-react-app with craco

I'm having an issue importing a component from one React project into another. The problems seems very basic but I'm having a really hard time figuring out where the problem is and what is the exact craco configuration to achieve my goal. Exporting…
Mateus Wolkmer
  • 636
  • 4
  • 20
5
votes
1 answer

My React app is using values from the .env file instead of the .env.local file

The dotenv module should be prioritizing my .env.local file over my .env file, but it's not. When I have REACT_APP_API_BASE set in both files, the app always uses the value in .env. It only uses the value in .env.local if I delete the matching…
carpiediem
  • 1,376
  • 12
  • 29
5
votes
1 answer

How to get require.context to work with Create React App with/withou Craco?

I'm trying to do some requires during runtime through require.context in my CRA (with Typescript) project, but I'm only getting these kinds of errors: TypeError: __webpack_require__(...).context is not a function and Critical dependency: require…
o01
  • 4,178
  • 10
  • 36
  • 69
4
votes
1 answer

Lerna monorepo NestJS & Create React App: Works find in dev mode, but build fails

I create a lerna monorepo with two packages: A vanilla NestJS app and CRA generated app. Here I used craco to import other packages from the monorepo. Inside the NestJS package I have a simple class that I want to share / use in the react app. It…
4
votes
1 answer

Adding svgr to create-react-app via craco

I want to use svgr's webpack plugin with create-react-app to use SVGs with MaterialUI's SvgIcon. I'm using craco to add svgr to Webpack's config. Currently, whenever the SVG is supposed to be rendered, the following error is thrown: Failed to…
John Smith
  • 2,086
  • 1
  • 9
  • 22
3
votes
0 answers

How can I add support for web workers in a CRACO Webpack application?

I want to leverage web workers in my react app. I decided to use threads as my supporting library. For this to function with a webpack bundle threads-plugin must be included. I happen to use CRACO and so I am still able to modify my webpack…
Womble
  • 185
  • 2
  • 12
3
votes
0 answers

Webpack Code Splitting - Prevent Duplicate CSS File in Build

I've bootstrapped my app with Create-React-App version 3.4.1 and am using Craco version 5.6.4 to make modifications to the Webpack config CRA provides. Due to specific client expectations which are out of my control, I need to end up with…
huntermacd
  • 47
  • 3
3
votes
1 answer

jest test cannot import cesium using create react app and craco

I am using create react app with craco, and craco-cesium to load cesium into my project. I am trying to setup jest to start creating tests but the issue is Cesium is using requireJS. I added the following to my package.json // package.json ... …
ArmenB
  • 1,770
  • 2
  • 18
  • 40
2
votes
1 answer

How to use ts-nameof with create-react-app or craco?

I want to use ts-nameof in my React app created with create-react-app. How can I do that without ejection? Hint: I also use craco, so a solution involving craco would be also fine for me. Thanks!
stefan.at.wpf
  • 13,061
  • 31
  • 116
  • 199
2
votes
1 answer

How to set up Tailwind responsive variants for production build?

I set up responsive variants in my create-react-app app after setting up Craco according to Tailwind Docs. These work perfectly in development build but no images load in production build. What am I missing here? I have determined the issue is most…
Jesse
  • 85
  • 5
2
votes
1 answer

Change antd variables at runtime with craco

I have to be able to change ant design variables at runtime (not via theme less files). I've found plenty of examples of this using customize-cra and react-app-rewire-less, but none seem to work with craco. I have to use craco because I'm also using…
Mateus Wolkmer
  • 636
  • 4
  • 20
2
votes
1 answer

How can I selectively render code in a Create React App SPA?

In my React app (built with Create React App cli, and not ejected) I have it set up so if there is no REACT_APP_API_URL defined then it uses mocked data. I do this by suppling a fakeFetch function to redux-api-middleware ala import { apiMiddleware…
Dave Sag
  • 12,289
  • 8
  • 77
  • 118
2
votes
0 answers

Warning: Value assigned to primitive will be lost for craco config

The following craco config has been taken as is from multiple articles on the internet that show how to include your monorepo UI library into the CRA build flow: const path = require('path'); const { getLoader, loaderByName } =…
Sammy
  • 2,087
  • 2
  • 28
  • 66
2
votes
1 answer

React craco tailwind postcss integration

My project use craco to start/build, I wish to integrate tailwind postcss. I have follow this tutorial https://dev.to/ryandunn/how-to-use-tailwind-with-create-react-app-and-postcss-with-no-hassle-2i09 But as a result, I am suffering with this…
sefirosu
  • 2,248
  • 6
  • 36
  • 61
2
votes
1 answer

Storybook with craco - call a different verson of react-scripts

Storybook currently calls react-scripts. However, I've got some parts of the CRA config overriden with craco. It means my application is invoked with craco ..., rather than react-scripts .... Is there a clean solution to have Storybook call craco…
John Smith
  • 2,086
  • 1
  • 9
  • 22
1
2 3 4 5