简体   繁体   中英

Deploy Angular Application in GitHub Pages

I have a GitHub pages website that uses a custom domain.

The domain serves a webapp made in Angular but when I access my domain the.js and.css files are not loading and on DevTools/Network I see a 404 Not Found per each.js or.css file I have on the branch assigned to the GitHub pages domain.

我的 gh-pages 分支上的 Js 和 CSS 文件

DevTools 网络选项卡上显示的错误

It's a common problem in Angular. When you generate the bundles you need to use:

ng build --prod --base-href ./ 

to set base-href to the root folder containing the bundles. Or if you already deployed the project just edit index.html and change the base tag to

 <base href="./">

More information in the docs .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM