Search code examples
angulargithubtravis-cigithub-pages

My Angular app is blank on gh-pages, can't load js from travis


I uploaded an app I built with Angular, Travis upload it on Github pages with the gh-pages branch but this time all I get is a blank page and the following error messages in the console :

Échec du chargement pour l’élément dont la source est « https://hdz.github.io/runtime.js ». [FCS-Training:14:1]
Échec du chargement pour l’élément dont la source est « https://hdz.github.io/polyfills.js ». [FCS-Training:14:1]
Échec du chargement pour l’élément dont la source est « https://hdz.github.io/styles.js ». [FCS-Training:14:1]
Échec du chargement pour l’élément dont la source est « https://hdz.github.io/vendor.js ». [FCS-Training:14:1]
Échec du chargement pour l’élément dont la source est « https://hdz.github.io/main.js ». [FCS-Training:14:1]

he doesn’t seem to load the whole js that it’s been deployed by Travis CI. https://hdz.github.io/FCS-Training/ here is the supposed github pages, the repository is here https://github.com/Hdz/FCS-Training

I can’t see what I’m doing wrong ? Works like a charm in local:

Date: 2020-07-18T10:08:54.367Z - Hash: e5b89a7c4ac0441d6496
4 unchanged chunks
chunk {main} main.js, main.js.map (main) 88.2 kB [initial] [rendered]
Time: 311ms

I used to deploy like this and it worked but there might has been changes or I did some mistakes ? Travis build is also passing.

Can anyone tell me what I am doing wrong? Thanks!


Solution

  • You should change the build script in your package.json to :

    "ng build --base-href ./ "
    

    The reason it's not working in your repository is that the angular CLI by default use base href="/" in the index.html, consequently the browser can't locate the missing resources.

    YOu can find more information about this in doc