03. folder-structure.md【create-react-app】


id: folder-structure
title: Folder Structure


After creation, your project should look like this:

應(yīng)用創(chuàng)建后,項(xiàng)目結(jié)構(gòu)類似:

my-app/
  README.md
  node_modules/
  package.json
  public/
    index.html
    favicon.ico
  src/
    App.css
    App.js
    App.test.js
    index.css
    index.js
    logo.svg

For the project to build, these files must exist with exact filenames:

項(xiàng)目中一些文件是必須的,并且文件名也不可以更改

  • public/index.html is the page template;
  • public/index.html 是頁面的HTML模板;
  • src/index.js is the JavaScript entry point.
  • src/index.js 是應(yīng)用的入口。

You can delete or rename the other files.

其他的文件都是可以刪除或重命名的。

You may create subdirectories inside src. For faster rebuilds, only files inside src are processed by Webpack. You need to put any JS and CSS files inside src, otherwise Webpack won’t see them.

可以在 src 下創(chuàng)建子目錄;為了加快應(yīng)用構(gòu)建、打包速度,Webpack只會處理 src 目錄下的文件;任何需要被處理的文件 都必須要放在 src 目錄下。

Only files inside public can be used from public/index.html. Read instructions below for using assets from JavaScript and HTML.

只有 public 目錄下的文件會被使用在 public/index.html 中。 起其他的如 JavaScript 和 HTML 請參考之后的說明。

You can, however, create more top-level directories. They will not be included in the production build so you can use them for things like documentation.

當(dāng)然,可以在項(xiàng)目的根目錄創(chuàng)建其他的文件夾,這些文件夾都不會被打包到生產(chǎn)環(huán)境中,因此可以用于項(xiàng)目文檔等用途。

If you have Git installed and your project is not part of a larger repository, then a new repository will be initialized resulting in an additional top-level .git directory.

如果是使用 Git 做項(xiàng)目的版本控制,項(xiàng)目根目錄還會包含 .git 頂級目錄。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容