I
I
Igor2020-06-13 11:38:58
React
Igor, 2020-06-13 11:38:58

Why is create-react-app creating so many files?

npx create-react-app testI create a react app with a team . Next, I delete unnecessary files.

project structure after deleting unnecessary files and editing

node_modules /
public /
- index.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>React App</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
  </body>
</html>

src /
- index.js
import React from 'react';
import ReactDOM from 'react-dom';


ReactDOM.render(
  <div className="app" />,  
  document.getElementById('root')
);

.gitignore
packege.json
packege-lock.json
README.md
Next, I call the command , I have a buildnpm run build folder in the root of this project, and it contains 100500 files. Where did they come from and why? Where did the workers come from if I deleted them (both the files themselves and from the code)? How to disable all this and make it to get ~ 1-2 js files at the output?
build folder structure

build /
- static /
- - 2.4ef118ec.chunk.js
- - 2.4ef118ec.chunk.js.map
- - 2.4ef118ec.chunk.js.LICENSE.txt
- - main.5b3f2f8f.chunk.js
- - main.5b3f2f8f.chunk.js.map
- - runtime-main.c8f0954f.js
- - runtime-main.c8f0954f.js.map
- asset-manifest.json
- index.html
- precache-manifest.6eda938e60060d1b83581433b421273b.js
- service-worker.js


PS And the most important question. Why would a newbie blow their brains out with all this? On the create-react-app.dev or reactjs.org site, I didn't find anything about building.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Shumov, 2020-06-13
@inoise

What is in the build folder should not particularly worry. React has a lot of logic to optimize loading from the client side. Well, who said that React is for beginners? For beginners in such frameworks, as it were, there is nothing to do)

D
Dmitry, 2020-06-13
@dimoff66

create-react-app appName creates an empty app from which the beginner only needs the app.js and app.css files to start developing. All other files are system or additional libraries. node_modules contains thousands of useful-useless libraries, but it makes little sense to look there, except perhaps for informational purposes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question