React build vs (?) Webpack?

1

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

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

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

I may be talking nonsense about the "vs" in the title of the question, but what is the difference between the two? Can I use either one or the other? Or do they both use the same system to compile?

Thanks for the hugs.

    
asked by anonymous 23.05.2018 / 16:14

1 answer

1

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

  

Create React apps with no build configuration.

Prior to the existence of create-react-app , you should implement your own "system" build. It could be webpack, gulp, or even grunt.

That meant you built your whole project, cute, with JSX, ES6, Sass, and you had to use one of these tools and define what they would do. Transpilar, minify, lintar and everything else you wanted. It was a great job, involving a lot of scripting and lots of google search, a very complicated entry barrier for anyone who wanted to start programming with React.

create-react-app has come to facilitate this whole configuration and build part, and let you focus only on your project. Behind the scenes he uses the webpack , with scripts that are very large, to do all this annoying part that you had to do beforehand.

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

    
23.05.2018 / 18:57