CareyWang / sub-web

https://sub-web.netlify.app/
MIT License
5.01k stars 1.85k forks source link

sub-web静态资源加载错误 #128

Closed Yofo-me closed 1 year ago

Yofo-me commented 1 year ago

sub-web在yarn build后将生成的dist目录下的所有文件放在网站的sub目录下,直接访问网站域名/subcss js会加载失败,用chrome调试功能发现:本应该是网站域名/sub/css/*.css实际访问的是网站域名/css/*.css,;本该是网站域名/sub/js/*.js实际上是网站域名/js/*.js。手动在网站的conf中加了这些配置(如图所示),但还是不行 网站的conf

请问如果要把sub-web部署在网站的子目录下,应该怎么弄呢?

Yofo-me commented 1 year ago

一些错误

GET https://analytics.ytt.yt/umami.js net::ERR_ABORTED 502

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

A bad HTTP response code (404) was received when fetching the script.

Error during service worker registration: TypeError: Failed to register a ServiceWorker for scope ('https://域名/') with script ('https://域名/sub-web.js'): A bad HTTP response code (404) was received when fetching the script.

GET https://域名/manifest.json 404 (Not Found)

Manifest: Line: 1, column: 1, Syntax error.
hinak0 commented 1 year ago

vue.config.js添加如下配置:

module.exports = {
  publicPath: "./", 
}

重新编译即可。 不要使用nginx的路由,太麻烦。