在我的本地主机上一切正常。
然后我使用ng deploy --base-href=/dentist-angular/
将我的应用程序部署到Github Pages。
我的文字应该放在的每个部分都有一个HTTP错误响应。您应该知道,所有文本都已使用NGX translation提取到页面中-因此,我认为这是问题的一部分。
我已删除并重新部署,但问题仍然存在。
控制台中的错误消息...
Object { headers: {…}, status: 404, statusText: "Not Found", url: "https://jamesross06000.github.io/assets/i18n/fr.json", ok: false, name: "HttpErrorResponse", message: "Http failure response for https://jamesross06000.github.io/assets/i18n/fr.json:
这很可能是路径问题,但是当我完全按照安装和部署说明进行操作时,我不确定从这里尝试什么。
HTML ...
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Dentist</title>
<base href="https://jamesRoss06000.github.io/dentist-angular/"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script src="env.js"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="styles.748d964c6c80975e08dc.css"></head>
<body>
<app-root></app-root>
<script src="runtime-es2015.edb2fcf2778e7bf1d426.js" type="module"></script><script src="runtime-es5.edb2fcf2778e7bf1d426.js" nomodule defer></script><script src="polyfills-es5.6696c533341b95a3d617.js" nomodule defer></script><script src="polyfills-es2015.2987770fde9daa1d8a2e.js" type="module"></script><script src="main-es2015.c08ed25e5c5c9aef5a4b.js" type="module"></script><script src="main-es5.c08ed25e5c5c9aef5a4b.js" nomodule defer></script></body>
</html>
难道在GitHub上使用NGX转换是一个很大的禁忌吗?
如果您需要查看控制台中记录的错误,这里是Github Pages URL。
这是一个错误,在控制台日志中重复了几次...
ee @ main-es2015.c08ed25….js:1
这是创建的dist文件夹中的文件结构...
感谢您的帮助。
答案 0 :(得分:1)
我找到了一个解决方案,尽管我没有解释为什么它以前不起作用。
要构建Angular 8项目并将其部署到Github页面,请使用以下...
npm install -g angular-cli-ghpages
ng build --prod --base-href "<repo-name>"
ngh --dir dist/<project-name>
上面为我完成了窍门。