Ionic-cli: Can't host build output in subfolder

Created on 31 Aug 2018  Â·  3Comments  Â·  Source: ionic-team/ionic-cli

Description:

When building an ionic v3 project with ionic build --prod, I was able to copy the www folder to a subfolder on my server to host it. With ionic v4 project this is not possible as it must sit in the root.

Similarly, I am not able to open the local index.html file on my computer to test it before uploading to the server, as I used to be in the past.

Steps to Reproduce:

ionic start test blank --type=angular
ionic build --prod

Try open www/index.html in browser.

Output:

My ionic info:

$ ionic info
√ Gathering environment info - done!

Ionic:

   ionic (Ionic CLI)          : 4.1.1 (C:\Users\Brent.SST\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.5
   @angular-devkit/core       : 0.7.5
   @angular-devkit/schematics : 0.7.5
   @angular/cli               : 6.1.5
   @ionic/ng-toolkit          : 1.0.7
   @ionic/schematics-angular  : 1.0.5

System:

   NodeJS : v8.9.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.1.0
   OS     : Windows 8.1

Other Information:

See discussion here: https://forum.ionicframework.com/t/ionic-build-generates-a-blank-page/140366

triage

Most helpful comment

Ran into this issue and learned that the base href must be set.

I have seen different answers as to how to resolve it. I went with /subdirectory/ and it worked. I have see that ./ also works.

If you are using IIS, you will have to configure an URL rewrite rule

All 3 comments

Ran into this issue and learned that the base href must be set.

I have seen different answers as to how to resolve it. I went with /subdirectory/ and it worked. I have see that ./ also works.

If you are using IIS, you will have to configure an URL rewrite rule

FYI, I also had to address the base href within manifest.json

FYI, I also had to address the base href within manifest.json

I build it with ionic build --prod -- --base-href "/sub/"

it worked without updating ./ in the manifest

Was this page helpful?
0 / 5 - 0 ratings