在github页面上部署我的角度应用程序,但在控制台的网站上出现错误

时间:2018-04-30 18:26:09

标签: angular github angular-cli-ghpages

我已经在github页面上成功发布了我的应用程序,但我的网站没有显示任何内容。 这是我的github存储库链接:https://github.com/chirag299051/Ice-and-Fire

我在控制台中遇到的错误:

inline.318b50c57b4eba3d437b.bundle.js Failed to load resource: the server responded with a status of 404 ()
polyfills.b6b2cd0d4c472ac3ac12.bundle.js Failed to load resource: the server responded with a status of 404 ()
scripts.e2cc764d74d6cb8d1c42.bundle.js Failed to load resource: the server responded with a status of 404 ()
main.54e8c9147109b23af744.bundle.js Failed to load resource: the server responded with a status of 404 ()
styles.a9b0b1037568d3083749.bundle.css Failed to load resource: the server responded with a status of 404 ()
polyfills.b6b2cd0d4c472ac3ac12.bundle.js Failed to load resource: the server responded with a status of 404 ()
scripts.e2cc764d74d6cb8d1c42.bundle.js Failed to load resource: the server responded with a status of 404 ()
main.54e8c9147109b23af744.bundle.js Failed to load resource: the server responded with a status of 404 ()
styles.a9b0b1037568d3083749.bundle.css Failed to load resource: the server responded with a status of 404 ()

1 个答案:

答案 0 :(得分:1)

您的脚本位于https://chirag299051.github.io/Ice-and-Fire,而您的应用正在尝试从https://chirag299051.github.io/获取它们。

制作它以便您从https://chirag299051.github.io/Ice-and-Fire获取脚本。

例如,https://chirag299051.github.io/main.54e8c9147109b23af744.bundle.js应为https://chirag299051.github.io/Ice-and-Fire/main.54e8c9147109b23af744.bundle.js

您可以通过使用--base-href标记构建项目并在<base href>see the documentation for more information.

中设置index.html标记来设置这些路径

在您的情况下,这会导致

ng build --base-href=/Ice-and-Fire/

index.html看起来像这样

<html>
  <head>
    <base href="/Ice-and-Fire/">
    ...
  </head>
  <body>...</body>

</html>