Skip to main content

文件夹结构

创建后,你的项目应如下所示:

¥After creation, your project should look like this:

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:

  • public/index.html 为页面模板;

    ¥public/index.html is the page template;

  • src/index.js 是 JavaScript 入口点。

    ¥src/index.js is the JavaScript entry point.

你可以删除或重命名其他文件。

¥You can delete or rename the other files.

你可以在 src 中创建子目录。为了更快地重建,webpack 只处理 src 中的文件。你需要将任何 JS 和 CSS 文件放入 src 中,否则 webpack 将看不到它们。

¥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.

public/index.html 只能使用 public 中的文件。阅读下面的说明,了解如何使用来自 JavaScript 和 HTML 的资源。

¥Only files inside public can be used from public/index.html. Read instructions below for using assets from JavaScript and 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.

如果你安装了 Git 并且你的项目不是更大存储库的一部分,那么将初始化一个新的存储库,从而产生一个额外的顶层 .git 目录。

¥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.