-
Notifications
You must be signed in to change notification settings - Fork 12k
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
feat: implement --base-href argument #1506
Conversation
ea99974
to
f9e08c7
Compare
f9e08c7
to
b216b06
Compare
Awesome work! Can't wait to see it merged in. |
@dzonatan my apologies, I took too long to review this PR and meanwhile there were some big changes in the files you edited. I looked through your test suite and it looks good. Can you rebase to the latest master? Also, can you add the |
b3925fc
to
35413c6
Compare
Done. Also added |
```bash | ||
# Sets base tag href to /myUrl/ in your index.html | ||
ng build --base-href /myUrl/ | ||
ng serve --base-href /myUrl/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to have this flag in the serve command? I'd expect the app to not work since the Dev server isn't aware of it. Haven't tested though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh. You're right! The given example will not work as expected.
I was just thinking about the opposite case: when using production value in index.html and you need to override it back to "/" when developing. But seems that would be the only working case. So I will remove it form serve
and rebase master.
Left a question but otherwise lgtm! |
35413c6
to
8dd2cfe
Compare
@filipesilva updated according to your comments |
Ah there's something else that I remembered now: the github deploy command does it's own base tag replacement: This logic needs to go into the build options now. Basically, if You'll probably want to have the Also, these tests should now not try and test the base href functionality, since that's part of the build task now (and I can't imagine a good way to test it from within this test anymore): There's a few instances of this check mind you. |
8dd2cfe
to
c159363
Compare
I'm not the expert of github pages so here some questions:
Anyway, I pushed a new commit for easier review. Please look at it. |
|
||
let lastHash: any = null; | ||
|
||
module.exports = Task.extend({ | ||
run: function(runTaskOptions: ServeTaskOptions) { | ||
run: function(runTaskOptions: BuildOptions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange, that nobody has noticed yet that build-webpack
and build-webpack-watch
tasks uses the options interface from serve
command. 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like one of those things that slipped :/
|
Just noticed that had already done what I suggested via the |
Reviewed and flagged it as LGTM. It will be merged soon to be on the next release. Thank you so much for this feature! |
Cool! But I see new conflicts.. again. 😄 Do I need to solve them? |
They're probably lint related, since I a big linting PR just got pushed. If you can look at them I'd appreciate it, but I expect it to be minor stuff as far as your PR is concerned. |
Implement --base-href argument for build and github-pages:deploy commands Closes angular#1064
49df2da
to
1e1ef93
Compare
Reuse basehref handling logic from webpack build task
1e1ef93
to
f94a022
Compare
Forgot to notify that I rebased it yesterday. |
It's in! Thanks @dzonatan for all the work you put in this functionality, you should be able to use it in the next webpack release :D |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
With this change we add hybrid rendering support in common engine, express engine and hapi engine. Users don't need to do any changes to take advantage of this change. The engine will serve the static prerendered page if a index.html exists for the given route, otherwise it will fallback to render the page in SSR. Closes angular#1506
Closes #1064
Implement
--base-href
argument for build and github-pages:deploy commands.Works as described in this comment.
One thing I did not fulfil from @filipesilva comment is:
Everything I found was "updateBaseHref" method which uses this
/<base href="\/">/g
regex. After investigation it turns out that it will only replace the current<base href="/">
(it must be declared this way in your index.html otherwise it won't work) tag. Also I don't get why regexg
modifier is used when base tag can be only one per page. Therefore I made my own regex to meet the insert whole tag (if not exists) & replace only href (if exists) requirements.