How to disable babel-loader in webpack using craco config? - reactjs

I've added esbuild to my CRA project using craco-esbuild. But it seems webpack still continue use default babel-loader to transpile my ts/tsx code. How can I disable it using craco config?

Related

How can i solve cant find module: "sass" error?

I'm new to react and decided to try another method to start a project instead of create-react-app which i regret, I used a site createapp.dev which uses a parcel bundler instead of react-scripts bundler so after i was done with the project i tried deploying it to github pages but could not i've read the parcel documentation but still no help so i restarted the project with create-react-app then copied the code but now i'm swimming in a bunch of errors
1.Install missed packages
if you use:
1.npm : npm install --save react-router-dom sass-loader sass
2. yarn : yarn add react-router-dom sass-loader sass

Can someone tell me how I can add PostCSS to CRA correctly?

All I found was to add a postcss cli or do an eject and change the webpack configuration
Can anyone tell me how to do it properly with eject?

How can I intregate ESLint in a Vite+React project?

When I create a React application using Create React App, ESLint is included by default. That's why we don't want to integrate ESLint manually. But when I create a React application using Vite there doesn't exist any kind of linting like ESLint or JSLint .
How can I install ESLint in a Vite+React project?
create-react-app has put their eslint rules into a dedicated package:
https://www.npmjs.com/package/eslint-config-react-app
Follow their instructions to set it up:
npm install --save-dev eslint-config-react-app eslint#^8.0.0
or
yarn add -D eslint-config-react-app eslint#^8.0.0
and then create an .eslintrc.json with this content:
{
"extends": "react-app"
}
This is already sufficient for VSCode to start linting in the editor. (provided you have an eslint plugin installed)
To manually trigger the linting process, you can add this to the scripts part of your package.json:
{
"scripts": {
"lint": "eslint --max-warnings=0 src"
}
}
and run it via npm run lint or yarn lint.
You could also use vite-plugin-eslint to have vite give you feedback in the console.
If you want to have eslint installed globally in your machine, you can open a console and add npm istall -g eslint, this will allow you to use the eslint cli to initialize the eslint config file in your projects (you can still use the eslint cli without install it globally, so this step is optional)
For install it in a React project, if you have never done it before you can follow next steps:
Do a npm istall eslint --save-dev or yarn add -D eslint and after it install the eslint plugin for React with npm install eslint-plugin-react --save-dev or yarn add -D eslint-plugin-react.
Once both dependencies are installed just open a terminal in the root of the project and run the command eslint --init (if you previously installed eslint globally, if not then use npx eslint --init), that will execute the eslint cli and create an .eslintrc.json file in your project with basic configs added already.
You can check the doc for the eslint-plugin-react package to understand better how to add more rules to the file and the rules supported by that plugin.
https://www.npmjs.com/package/eslint-plugin-react
And this article should also help you https://medium.com/#RossWhitehouse/setting-up-eslint-in-react-c20015ef35f7

I get webpack not installed, but webpack --version finds webpack

I am following this tutorial to create a React project with webpack. Everything went smooth until step 4 webpack --config webpack.config.js, where I get this error:
webpack not installed
Install webpack to start bundling:
$ npm install --save-dev webpack
But if I type webpack --version, I get 4.43.0.
I don't know what is wrong.
Based on the information you gave, your webpack.config.js might be invalid, e.g., importing missing module, or not exporting proper configuration.
See this issue for more context:
https://github.com/webpack/webpack/issues/9242#issuecomment-500350448

I am not able to build it using yarn

I am not able to build my react app using yarn run build;prod
Failed to minify the code from this file:
./node_modules/map-age-cleaner/dist/index.js:15
Is not Yarn problem you just spell it wrong.
Instead using yarn run build use yarn build.
This worked for me.
Yarn has nothing to do with minification.
Minification depends to webpack/parcel or the bundler you are using.

Resources