[英]How to deploy to vercel static files? only html, css and js
I found a solution - read my first answer.我找到了解决方案 - 阅读我的第一个答案。
I am trying to deploy a repository from my github.我正在尝试从我的 github 部署一个存储库。
The project contains some static files:该项目包含一些 static 个文件:
├─js
│ ├─form.js
│ ├─logic.js
│ └─anotherFile.js
├─index.html
└─styles.css
After I deploy the project (without choosing framework - choosing "other") I get 404 ( Failed to load resource
) when I enter the project from the new domain.部署项目后(不选择框架 - 选择“其他”),当我从新域进入项目时,我得到 404( Failed to load resource
)。
Just to mention, the project works fine locally when I open the index.html
file.顺便提一下,当我打开index.html
文件时,该项目在本地运行良好。
Since I used import statements inside my javacsript files it caused some problems when trying to access them when openning the index.html
.由于我在 javacsript 文件中使用了 import 语句,因此在打开index.html
时尝试访问它们时会导致一些问题。
I used webpack to solve that issue so I will use the build output.我使用 webpack 来解决这个问题,所以我将使用构建输出。 In vercel platform I chose the OUTPUT DIRECTORY
option as the relevent build output - dist
in my case.在 vercel 平台中,我选择了OUTPUT DIRECTORY
选项作为相关的构建输出 - 在我的例子中是dist
。
I found what has helped me when deploying static files is creating another folder inside the root directory.我发现在部署 static 文件时对我有帮助的是在根目录中创建另一个文件夹。 And then put all the files in the newly created folder.然后将所有文件放入新建的文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.