React build vs (?) Webpack?

Asked

Viewed 270 times

1

I’m taking a React course. I have an understanding of what React is, and what problem it solves.

However when I put in CMD "create-React-app x" it shows some other commands that I can use in this project among them the "npm run build" which theoretically compiles the project for its distribution version.

While in another video the instructor says to use the webpack to generate this build?

I may be talking nonsense about the "vs" in the question title, but what’s the difference between the two? Can I use both? Or both use the same system to compile?

Was worth hugs.

1 answer

2


First, what is the purpose of create-react-app? In the documentation:

Create React apps with no build Configuration.

Before the existence of create-react-app, you should implement your own build "system". It could be webpack, Gulp, or even Grunt.

This meant that you built your entire project, cute, with JSX, ES6, Sass, and you were required to use one of these tools and define what they would do. Sweat, minify, line and all you want. It was a very big job, involving several scripts and a lot of google search, very complicated entry barrier for those who wanted to start programming with React.

The create-react-app came to facilitate all this part of configuration and build, and let you focus only on your project. Behind the scenes he uses the webpack, with scripts until quite large, to make all this boring part that before you had to do on hand.

I recommend you create a new project, with the create-react-app and execute the command npm run eject. What this command does is to "unhook" everything it hides from configuration. Then you will see the webpack config file, see the scripts and everything else. Just be careful that once the project is "ejected", there is no going back.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.