-
Notifications
You must be signed in to change notification settings - Fork 12k
path in index #2568
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
Comments
Agreed, JS source files and the resulting HTML needs to have separate destination directories, and a simple HTML file with ONLY the resource script definitions would be very helpful. |
You can set base href with If you try to use base href to load these files from another directory, it will work, but also impact other URLs in your app. For example, say you want these files under /assets/ so you set --base-href=/assets/ This will work, but other relative URLs will be impacted. So angular-cli really needs something like a outResourcesUrlPrefix option. |
@arlowhite, If you didn't want your Changing the base href is really the way to go; lazy-loaded routes, image tags in templates, url()'s from inline CSS, etc. should all keep working as if the index.html was in its original location. |
My point was that in this scenario, you do want base href to impact your API URLs. Maybe you deploy under / sometimes, and /my-app/ other times and the angular-cli app is deployed alongside some service. Of course you could just prefix all your API URLs with some configurable variable. There are a lot of ways the developer can deal with the problem. But if angular-cli provided a resourceUrlPrefix option in addition to baseHref, it would be convenient for developers that use relative URLs in their app and also want to relocate the webpack resources to be served from another path. |
@arlowhite, my apologies. From the comment it seemed like you were just using the relative URL because it was quick and easy and happened to work. I would still caution against the approach, it's a little magical and a new developer taking over the project could very easily break things. And if the base href ever needed to be changed, there's going to be a large amount of find/replace. As a general pattern, I'd recommend an app config service containing app-wide settings that can be injected where needed. One of those can be the base API server URL. If needed this URL could even be computed at startup from |
Dupe of #2276 I think. If that's not the case, let me know and I'll reopen. |
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. |
OS?
Versions.
If you programm the angular app as part of another app for example Rails application the path of the css file and the javascriptfile is relativ to the public dir. If you put the angular part in for example public/ang the js and css file should have the path "ang/main.js in the index.html to load the javascripts and css.
Example 👍
the generated (ng build --prod) and modified index.html
this should be done via ng build --path "apollo/ang"
This feature would be very helpful to integrate angular2 with angular-cli in other application
The text was updated successfully, but these errors were encountered: