Can’t build create-react-app project with custom PUBLIC_URL

If the other answers aren’t working for you, there’s also a homepage field in package.json. After running npm run build you should get a message like the following: The project was built assuming it is hosted at the server root. To override this, specify the homepage in your package.json. For example, add this to build … Read more

How to set build .env variables when running create-react-app build script?

I imagine you got this working by now, but for anyone else that finds this, you set your default environment variables in a .env file at the root of your “create-react-app” project. To separate out the variables used when using npm start and npm run build you can create two more env files – .env.development … Read more

How is ESLint integrated into Create React App?

Yes, create-react-app comes with eslint config. How do I enable and extend it correctly? You can check how to extend it here. { “eslintConfig”: { “extends”: [“react-app”, “shared-config”], “rules”: { “additional-rule”: “warn” }, “overrides”: [ { “files”: [“**/*.ts?(x)”], “rules”: { “additional-typescript-only-rule”: “warn” } } ] } } How do I enable it? You need to … Read more

What is the difference between NextJs and Create React App

I’ve used both NextJs and CRA. Both these frameworks can be used to get started quickly and provide a good developer experience. However, both of these have use cases where either of them shines better. I’ll try to compare them based on some of these factors. Feel free to suggest edits with additional points or … Read more

Running CRA Jest in non-interactive mode

You should use Jests –watchAll=false flag. eg: npm test — –watchAll=false Note: this is for react-scripts > 3.00 For older versions: react-scripts >= 2.1.4 < 3.00 For non-ci, eg running tests locally, you can pass a –no-watch flag: npm test –no-watch react-scripts <= 2.1.3 CRA looks for a CI environment variable, if its present it … Read more

Where’s the connection between index.html and index.js in a Create-React-App application?

Under the hood, Create React App uses Webpack with html-webpack-plugin. Our configuration specifies that Webpack uses src/index.js as an “entry point”. So that’s the first module it reads, and it follows from it to other modules to compile them into a single bundle. When webpack compiles the assets, it produces a single (or several if … Read more

Is there an option to show all test descriptions when I run jest tests?

From Jest’s command-line options docs –verbose Display individual test results with the test suite hierarchy. So running jest –verbose Will print all the names in describe, it, test blocks. If you’re running tests with yarn, you can do yarn test –verbose If you’re running tests with npm, you can do npm test — –verbose If … Read more