-
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
No publicPath option in configuration file #2276
Comments
This would be great! My build isn't located on the server's base folder, but in the public folder. So after every build, i have to change the strings in my index.html manually again... |
Also, with this integration we can use the standard way of Lazy Loading modules with the router. |
Definitely +1 for this config option; our test and production servers use a subdirectory so having publicPath support is necessary for us but we'd only want it to be used when using the --prod flag during build or serve. |
You can use the |
@filipesilva : This does not solve de problem, the --base-href is only to provide root point for the Angular Route Path, not for the root of static files. |
@filipesilva I agree with @manuelcua as this is a separate config option for Webpack. The publicPath specifies the public URL address of the output files when referenced in a browser. For loaders that embed <script> or tags or reference assets like images, publicPath is used as the href or url() to the file when it's different than their location on disk (as specified by path). This can be helpful when you want to host some or all output files on a different domain or on a CDN. The Webpack Dev Server also uses this to determine the path where the output files are expected to be served from. As with path you can use the [hash] substitution for a better caching profile. |
Ok, seems I misunderstood it's use. I'd be happy to review a PR for this, but bear in mind it should have a test. |
Is there any update on this? |
any update on this? |
No one has tried to do a PR yet, so no, no update yet. |
I'm not experiencing any issues, but I did find this issue looking for an easy setting to separate the bundled files from distribution root folder, a custom task will do for now, fingers crossed for future. |
@filipesilva PR created for publicPath support including unit test |
How soon to have the PR merged? Need publicPath |
I need it as well. We can't store our javascript assets in the root of our server. |
Since changeLiuUNSW's PR is still pending, I found a temporary solution in the webpack docs for outputPath. It suggests that you can add import './polyfills.ts';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app';
declare let __webpack_public_path__: any;
__webpack_public_path__ = "https://cdn.somewhe.re/";
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule); I realize this workaround should (hopefully) only be valid until a PR that enables publicPath is merge. EDIT: Added variable declaration per below comment. |
Hi @filoxo , I tried to do the same as above, but still the |
Not sure why you'd need the public path in index.html if you could serve that from the same origin as your assets (eg. CDN). My use case is that my backend is Java/Spring, but the js/CSS files are served via a CDN. Therefore the initial `main.js` loads but the additional chunks weren't. Setting the publicPath simply tells webpack's require which origin to request those additional chunks from.
And yes, I did notice the `unresolved variable` error during the build; probably should have made note of that in my comment too. I chose to ignore it because it still built successfully, but if declaring it resolved the problem with the TypeScript compiler that'd be good you'd solve the error. Again, though this works the real solution is to build the config into the cli. Hence why I noted that it's a temporary solution until #3285 is merged.
|
Hmm, my use case is because we are trying to serve the I checked the the @filoxo Is your script and link are prefixed with the cdn path correctly ? |
I don't use the generated |
@filoxo Hmm, I've now shifted to parsing out |
@piyushchauhan2011 are you sure you're not just overlooking setting the |
…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
What's the latest on this issue, any PR yet or a work around? |
Nothing change until now :( |
The |
Again, deploy-url doesn’t change static assets paths, which publicPath does. |
I just tested --deploy-url to add public/static as a prefix for the src path and it worked as expected. command: output:
|
These paths are the main app files, not assets like images referenced in other HTML components. |
We only process images in CSS actually. Images in HTML are not processed. The tracking issue for HTML resource support is #3415. |
@filipesilva I'm using cli 1.6.0-rc.0, have set deploy-url to 'assets' in both command line and angular-cli.json. The bundles are prefixed with 'assets' in index.html, but bundle files not copied to the deploy-url folder - assets. |
Yeah, this fixed my problem. We set output path to 'bundles', and deploy-url to 'bundles' as well. The entry point is MVC action from URL /app/ which loaded view from bundles/index.html, so the actual URL (and base href) should be /app/, while the assets are loaded from /bundles/*. |
@filipesilva why do I get following error when I'm setting absolute url (http://...) to deploy-url parameter?
I need to set absolute path to that parameter to support MVC integration. |
@feng-xiao that sounds like a bug. Can you open a new issue for is to look at? |
@filipesilva Hi filipesiva, I entered the issues in #8847 |
@hpjc |
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. |
I´ve searched in the source but there´s no way of setting the "publicPath" of my application
It should be inside the webpack output configurations but looking at angualr-cli source it´s not available.
For me it is crucial because I prepend /static/dist/ to load javascript and assets on my app.
I´m using NG version 1.0.0-beta.15
I´m using Django as Server and only doing watch on ng build and Django puts it´s static files in /static/ folder and maps the base URL to a template index.html file so the hrefs in the index files are not relative to the static folder and gets a 404 error.
All of this gets solved if I could add the publicPath configuration in angular-cli.json or environment files
The text was updated successfully, but these errors were encountered: