Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base-href still not recognized / applied properly #4568

Open
sebastian-zarzycki-apzumi opened this issue Sep 25, 2020 · 7 comments
Open

base-href still not recognized / applied properly #4568

sebastian-zarzycki-apzumi opened this issue Sep 25, 2020 · 7 comments
Labels

Comments

@sebastian-zarzycki-apzumi

Description:
When --base-href is passed to the build command (i.e. for browser target), it doesn't result in index.html file with proper <base href /> tag

Steps to Reproduce:
ionic cordova build browser -- --base-href=/ionic/

Output:
Resulting index.html contents:

  <base href="/" />

Expected:

  <base href="/ionic/" />

as when building regular Angular app.

My ionic info:

Ionic:

   Ionic CLI                     : 6.11.9 (/opt/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.3.3
   @angular-devkit/build-angular : 0.1001.0
   @angular-devkit/schematics    : 10.1.0
   @angular/cli                  : 10.1.0
   @ionic/angular-toolkit        : 2.3.3

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : 6.0.0, android 9.0.0, browser, ios 6.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 12 other plugins)

Utility:

   cordova-res : 0.15.1
   native-run  : 1.1.0

System:

   Android SDK Tools : 26.1.1 (/Users/rattkin/Library/Android/sdk)
   ios-deploy        : 1.10.0
   ios-sim           : 8.0.2
   NodeJS            : v12.18.3 (/opt/local/bin/node)
   npm               : 6.14.8
   OS                : macOS Catalina
   Xcode             : Xcode 12.0.1 Build version 12A7300

Other Information:
It seems that it is passed down the line, but just not respected. That command above results first in
ng run gpa-mobile:ionic-cordova-build --platform=browser
and later in
cordova build browser --base-href=/ionic/

But the index.html is not changed.

@ionitron-bot ionitron-bot bot added the triage label Sep 25, 2020
@imhoffd
Copy link
Contributor

imhoffd commented Sep 25, 2020

Here's some history: #3600

I don't think we want to add this option because it doesn't fit into the vast majority of how people are using the Ionic Framework. I would recommend splitting up the build commands and not using ionic cordova build if you want to continue with your current strategy.

Please keep in mind the browser platform is not fully supported: #2312 (comment)

@sebastian-zarzycki-apzumi
Copy link
Author

I saw that task (hence "still" in title). Actually, in there, your comment from 2y ago:

For example, Cordova should use --base-href=/, and PWA may use --base-href=app/, or similar. Because of this, we should abstract this low-level option. 

Anything changed in that regard?

Also, that's not even cordova related thing, Angular already supports that property in commandline.

If not using ionic cordova build, then what?

@imhoffd
Copy link
Contributor

imhoffd commented Sep 25, 2020

Ionic is more focused on improving the cross-platform aspect of PWAs with Capacitor, so I may close that issue sometime with an explanation. Basically, PWA support is better solved Capacitor and with your framework's tooling. We're not heavily investing in Cordova anymore.

If not using ionic cordova build, then what?

I just meant you can use ionic build -- --base-href=/ionic/ and then cordova build browser. The ionic cordova build combines those for convenience.

@sebastian-zarzycki-apzumi
Copy link
Author

Would that make any difference, though? (using ionic build with that switch, that is)

@ghost
Copy link

ghost commented Oct 16, 2020

@dwieeb @sebastian-zarzycki-es I have the same issue, i used to build my webapp with ionic cordova build browser --prod --release but now i want to be able to serve different versions in the server. http://mydomain/version1 and http://mydomain/version2
I tried different things like:
ionic build -- --base-href=/version1/ and then cordova build browser
ionic build --prod -- --base-href /version1/ and then cordova build browser
ionic build --prod -- --base-href=/version1/ --deploy-url /statics/app/ and then cordova build browser
ionic cordova build browser --prod -- --base-href=/version1/

I check the index.html inside /www have a any difference or includes something related with the new base-href, but no references to it.

i still get the expected 404 error. f.e: initializing the web tries to get from /assets/** instead of version1/assets/**

There is any solution ??

Thanks!!

@sebastian-zarzycki-apzumi
Copy link
Author

No. You have to change it manually or change your build process to use two subcommands stated above. Keep in mind that the resulting build won't be in /www.

@ghost
Copy link

ghost commented Oct 22, 2020

it worries me that in the index.html it does not appear any reference to <base href="/" />

All the builds i make with the diferents values are created in the build folder /platforms/browser/www

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants