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

feat(build): add publicPath support via command and angular-cli.json #3285

Merged
merged 1 commit into from Dec 29, 2016

Conversation

Projects
None yet
@changLiuUNSW
Copy link
Contributor

commented Nov 25, 2016

Add publicPath option for webpack.

User can specify publicPath via --deploy-url / -d from command line or add deployUrl to angular-cli.json

It can solve following issues:

  1. Change the public URL address of the output files (different from baseUrl).
  2. Manipulate the request url for chunk js files.

It is very helpful to solve resources url and route lazying load issues for those applications which have different static files paths such as ASP.NET MVC.

This should fix
#3136
#2960
#2276
#2241
#3344

@googlebot

This comment has been minimized.

Copy link

commented Nov 25, 2016

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.
@changLiuUNSW

This comment has been minimized.

Copy link
Contributor Author

commented Nov 25, 2016

I signed it!

@googlebot

This comment has been minimized.

Copy link

commented Nov 25, 2016

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels Nov 25, 2016

@changLiuUNSW changLiuUNSW force-pushed the changLiuUNSW:add-publicPath branch 7 times, most recently from c5a5523 to beac9b3 Nov 25, 2016

@mwaa

This comment has been minimized.

Copy link

commented Nov 27, 2016

What's the status of this?

@naveedahmed1

This comment has been minimized.

Copy link

commented Nov 27, 2016

@filipesilva can this be included in next release?

@changLiuUNSW changLiuUNSW force-pushed the changLiuUNSW:add-publicPath branch 2 times, most recently from 4eefd83 to 2ebdd7b Dec 1, 2016

@changLiuUNSW

This comment has been minimized.

Copy link
Contributor Author

commented Dec 1, 2016

@filipesilva Could you please review this PR? Thx

@changLiuUNSW changLiuUNSW force-pushed the changLiuUNSW:add-publicPath branch from 2ebdd7b to 1e5882b Dec 1, 2016

@filoxo filoxo referenced this pull request Dec 2, 2016

Closed

add support for publicPath #3344

@mattetti

This comment has been minimized.

Copy link

commented Dec 2, 2016

We also had to use a similar patch in our app, let's hope this gets merged ASAP

@changLiuUNSW changLiuUNSW force-pushed the changLiuUNSW:add-publicPath branch 3 times, most recently from 0acd542 to 392caf0 Dec 2, 2016

@mildfuzz

This comment has been minimized.

Copy link

commented Dec 5, 2016

any chance this could get merged?

@hansl hansl merged commit 0ce64a4 into angular:master Dec 29, 2016

3 checks passed

cla/google All necessary CLAs are signed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@halfonf

This comment has been minimized.

Copy link

commented Jan 10, 2017

Where can I find the documentation about this ?
I need to add a deployurl in angular-cli.json and call ng build -d ??

Thx

@changLiuUNSW

This comment has been minimized.

Copy link
Contributor Author

commented Jan 11, 2017

@halfonf
Either way is OK

@changLiuUNSW changLiuUNSW deleted the changLiuUNSW:add-publicPath branch Jan 11, 2017

@halfonf

This comment has been minimized.

Copy link

commented Jan 11, 2017

@changLiuUNSW
thx

From which version is it enabled ?

@changLiuUNSW

This comment has been minimized.

Copy link
Contributor Author

commented Jan 11, 2017

Not publish yet. You have to wait....

@halfonf

This comment has been minimized.

Copy link

commented Jan 11, 2017

@changLiuUNSW

thx I hope it will be released soon :)

@halfonf

This comment has been minimized.

Copy link

commented Jan 12, 2017

Hi Chang

I saw on stackoverflow that you automatized the cshtml edition.
You approach sounds great.
Can you share the gulp code you wrote to generate the json file and the mvc code integrate it ?

Thx a lot

Found a solution thx anyway

@mmc41

This comment has been minimized.

Copy link

commented Jan 13, 2017

Saw that this new feature is released now. How is it actually used?
In my case, I need to serve all files in "localhost/ui" rather than "localhost/" but I can't get this feature to do that ?

@Meligy

This comment has been minimized.

Copy link
Contributor

commented Jan 13, 2017

@mmc41 I have the same scenario as you. I need to serve (and deploy) app as something like /all-apps/my-app/. I have achieved that using the existing --base-href option (-bh for short, works with both ng build and ng serve, although in my case I was using ng build --watch as I serve my app via IIS).

I just set it like this: ng build -bh '/all-apps/my-app/' . I have my IIS application (web server wwwroot if you may) set to the dist folder.

@mmc41

This comment has been minimized.

Copy link

commented Jan 13, 2017

@Meligy I am also using -bh but could only get it to work for ng build. If I try it with ng serve, I get an error that the option is not recognised. Thus I can serve the finished distribution under a "ui/" subpath but not when I am developing and just using "ng serve"

@Meligy

This comment has been minimized.

Copy link
Contributor

commented Jan 13, 2017

Interesting. I believe I got it working with ng serve too. It's not on the same computer I'm posting from. I might be mistaken because I use ng build --watch instead. Sorry for that.

Maybe just setting the <base> tag in the HTML itself will work for serve. Otherwise, might have to dig in the code change in this PR.

@filipesilva

This comment has been minimized.

Copy link
Member

commented Jan 13, 2017

@mmc41 this PR is only for build, it does not add the functionality to ng serve.

When running ng build --deploy-url=deployUrl/, your app files will be in that folder (like deployUrl/main.bundle.js) and index.html will correctly reference them.

So you'd normally just run ng serve and get everything served on localhost, and then when you need to deploy you use ng build --deploy-url=deployUrl/ and copy over dist/.

@Bulan

This comment has been minimized.

Copy link

commented Jan 13, 2017

Is there any documentation around this somewhere?

Can I add this to be the default somewhere for ng build --prod?

@Meligy

This comment has been minimized.

Copy link
Contributor

commented Jan 14, 2017

The recommended way for such options as defaults is to create an npm script that calls the command with the options you need.

So, in package.json, you might have:

"scripts": {
  "start": "ng serve",
  "build:prod": "ng build -prod ....."
}

And you call it like:

npm run test:prod
@igormalyk

This comment has been minimized.

Copy link

commented Jan 31, 2017

@changLiuUNSW Hello, your PR is very valuable as it solves the exact same issue I have. The only thing I also need to be able to do this in dev as well with ng serve. Is there any plan to integrate this PR into ng serve?

@changLiuUNSW

This comment has been minimized.

Copy link
Contributor Author

commented Feb 2, 2017

@igormalyk
I believe @filipesilva has some plan to support it.
#4090

MRHarrison added a commit to MRHarrison/angular-cli that referenced this pull request Feb 9, 2017

feat(build): add publicPath support via command and angular-cli.json (a…
…ngular#3285)

Add publicPath option for webpack.

User can specify publicPath via `--deploy-url` / `-d` from command line or add `deployUrl` to `angular-cli.json`.

It can solve following issues:

Change the public URL address of the output files (different from baseUrl).
Manipulate the request url for chunk js files.
It is very helpful to solve resources url and route lazying load issues for those applications which have different static files paths such as ASP.NET MVC.

Fixes angular#3136
Fixes angular#2960
Fixes angular#2276
Fixes angular#2241
Fixes angular#3344
@filipesilva

This comment has been minimized.

Copy link
Member

commented Jun 12, 2017

@igormalyk support for ng serve was added in #6112.

@Malabarba

This comment has been minimized.

Copy link

commented Oct 2, 2017

Hi there. Has this feature made it to a release yet?
I'm trying to use it but can't get it to work even on @angular/cli: 1.5.0-beta.2.

@filipesilva

This comment has been minimized.

Copy link
Member

commented Oct 2, 2017

@Malabarba this has been released a long time ago. If you're experiencing problems with it please open an issue with reproduction steps for us to investigate.

@Malabarba

This comment has been minimized.

Copy link

commented Oct 2, 2017

Sorry. I think I may have misunderstood the feature.
I ended up ejecting ngcli and configuring webpack directly, and it took a lot more configuration to get what I wanted than just the option offered by this PR.

So, I guess what I'm saying is sorry for the noise. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.