简体   繁体   English

如何部署到 vercel static 文件? 只有 html、css 和 js

[英]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.

相关问题 压缩静态HTML文件中的JS和CSS - Compressing JS and CSS in Static HTML Files 如何将版本号添加到HTML文件(不仅是CSS和JS文件) - How to add version number to HTML file (not only to css and js files) 如何在 node.js ( 仅 node.js ) 中制作静态文件 (.css, .js) - how make static files (.css, .js) in node.js (only node.js) 如何在 Vercel 上使用 Mongoose(MongoDB)连接部署 Next JS App? - How to deploy Next JS App with Mongoose(MongoDB) connection on Vercel? 如何从 vercel 中的 static html 文件调用 expressjs 端点 - how to call expressjs endpoint from static html file in vercel 当我在 css 和 js 文件 url 上部署 nuxt static 应用程序时出错 - Error when I deploy a nuxt static app on css and js files urls 如何将 javascript 文件输出到 'static/js' 目录和 css 文件到 'static/css' 目录 - How to output javascript files into 'static/js' directory and css files into 'static/css' directory 如何为js和CSS嵌入html文件 - How to embed the html files for js and css 在html文件中有2个CSS代码块,如何仅使用JS进行一项工作? - Having 2 css code blocks in html files how to make only one work using JS? 如何在Rails应用程序中包含带有自定义css和js文件的静态页面 - How to include a static page with custom css and js files in a Rails application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM