index.html 和其他 html 文件应该放在哪里:根目录还是 dist / build 文件夹?

Where should index.html and other html files be located: root directory or dist / build folder?

在YouTube上的几个教程视频中,我看到在网站布局的过程中,index.html文件要么在根目录,要么在build/dist文件夹(用于生产的那个) .

相同的GitHub页似乎习惯于在根目录中查找index.html。在托管方面似乎是一样的(如果我错了就更正)。如果它位于 dist / build 文件夹中,它会被“找到”吗?

根本区别或标准是什么?

index.html 必须在 dist/ 文件夹中。

因为 dist/ 通常由 build-tools 或打包器生成并且包含(一般来说)整个可部署项目。

生成的 index.html 包含已打包并放入 dist/

中的脚本和样式以及其他资源的路径

最后,您可以构建 dist/ 并将其内容上传到远程服务器 /var/www,网站将启动 运行。

webpack 示例:

npx webpack -p # -p for production mode
scp -r dist/* remote-server.com:/var/www/