Angular-cli: Feature Request : ng build to include a --base-href <base>

Created on 11 Jun 2016  路  4Comments  路  Source: angular/angular-cli

Much like what happens as part of github deploy, have a feature that you can supply a base-href that will be added to the index.html during the ng build command

Usage : ng build --base-href <base>
Example : ng build --base-href home
Replaces <base href="/"> with <base href="/home"> in index.html

easy (hours) 1 (urgent) feature

Most helpful comment

@dzonatan I'm not seeing it anywhere in the commit, but are you able to configure this option in the environment files instead?

All 4 comments

I've started and actually did some work on this because I missed it in webpack version.. and I really need it. :|

To make sure I'm in the right way I need someone of angular members approval about how this argument should work.
Is it good for you to have such case scenarios:

  • if no --base-href tag provided then do nothing (keep the template index.html untouched). In such case the user is able to use base tag purely. This also ensures to don't have any breaking changes.
  • if --base-href x provided and base tag doesn't exists then insert <base href="x"> in header.
  • if --base-href x provided and base tag already exists then replace only the "href" attribute of base tag. (In case developer uses additional attribute(s) like "target").

Also I'm thinking that instead of auto-prefixing url with slash whole url should be provided by developer for the case when I want to overwrite my /xxx/ (which already sits in index.html) with just /.

I was gonna pick this one up, but if you're working on it I'm happy to help. I'm speaking as myself now, design for this feature hasn't been discussed within the team.

There's a couple of extra things you have to look into when developing this feature:

As far as behavior goes, I think your proposal makes sense. I also agree the developer should provide the whole URL.

@dzonatan I'm not seeing it anywhere in the commit, but are you able to configure this option in the environment files instead?

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings