Kelvinyu1117
Kelvinyu1117

Reputation: 529

Is it necessary to configure React.js environment(Webpack, Babel) nowadays?

I'm a React.js beginner. I usually start the project by using these commands and do not need any configurations:

npm install -g create-react-app
create-react-app my-app

However, I found that a lot of online tutorials start the project by configuring Webpack and Babel. They have to configure webpack.config.js.

Also, When I use "create-react-app" to start my project, I can't find this file, I have no idea how to configure my webpack.

My questions:

Is it necessary to start the project by this way?

What are the differences between configure the environment by ourselves and using the create-react-app to build the project?

Which one is the best or the most common?

Upvotes: 1

Views: 91

Answers (2)

Dream_Cap
Dream_Cap

Reputation: 2302

I think the answer depends on the situation of what you're trying to make. I think create-react-app is a good start, but it keeps the files that make the environment hidden from you until you do "npm run eject." There are many React boilerplates (pre-configured starter environments) out there that you can choose from. Here is a list: http://andrewhfarmer.com/starter-project/

As a person who is also learning React.js and someone who has spent so much time trying to find the "best" boilerplate, I think the best option is to start with a very small subset for what you need(babel, react npm package, webpack), and then progressively add what you need as you find out what you need for your project.

I think it's good to start with a small environment like this because if you go with an advanced boilerplate like Kriasoft's 'react-starter-kit', there may be a lot of terminology and extraneous things you may not need like tests(which is always a good practice to have, but you may not need it while learning basic React.js or making a small website). Some boilerplate/react-starter environments are also opinionated. For example, if you ever use Next.js, there is a small learning curve because it has you do things in the Next.js way, such as putting components in a "pages" folder to get them rendered.

Upvotes: 2

Justin Tien
Justin Tien

Reputation: 67

create-react-app encapsulation all script & package (include webpack, babel),

let you don't need to take these.

if you need to custom config, you can run npm run eject (one-way and can't go back)

you can see README.md https://github.com/facebookincubator/create-react-app

Upvotes: 0

Related Questions