🐞 Bug report
Command (mark with an x)
Is this a regression?
No
Description
I'm implementing the --localize flag in our application build. We are serving our assets from a CDN, and so far we were building separate applications with --locale=.. which was working fine, because we knew the locale and we could just specify --deployUrl=https://cdn.com/assets/${locale}.
However now moving to --localize flag I can't do that anymore, because there's a single build for all locales.
Actual problem
Since locale is actually added to the --baseHref=/assets/ forming
<href base="/assets/${locale}">
then I would almost expect the same thing to happen with --deployUrl because I don't know that suffix a priori.
Alternative solution
Another solution is constructing that path like
deployUrl + baseHref + locale + asset/path
And in that case running
$ ng build --baseHref=/assets/ --deployUrl=https://cdn.com/ --localize
would return the proper localized asset path with the cdn
What I'm running
So currently my ng build looks like
$ ng build --baseHref=/assets/ --deployUrl=https://cdn.com/assets/ --localize
and while baseHref works fine, the deployUrl points at (for example) https://cdn.com/assets/main.js instead of https://cdn.com/assets/${locale}/main.js which ends up as HTTP 404.
For the record in app.module.ts I have
{ provide: APP_BASE_HREF, useValue: '/' }
Similar issues
I was reading some other issues and probably the closest one was #16625
but we can't grep/replace the assets because of our PWA configuration and hash checking the assets.
So is my approach wrong here? or is it actually a bug?
🔬 Minimal Reproduction
https://github.com/marcinowski/ng-build-localize-issue
$ yarn build --baseHref=/assets/ --deployUrl=https://cdn.com/assets/ --localize
🔥 Exception or Error
$ ng build --baseHref=/assets/ --deployUrl=https://cdn.com/assets/ --localize
$ head -6 assets/en/index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<base href="/assets/en/">
$ tail -2 assets/en/index.html
<script src="https://www.cdn.com/assets/runtime.f95efe4dfa0fd0cf523c.js" defer>
🌍 Your Environment
$ ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 9.0.5
Node: 12.16.0
OS: linux x64
Angular: 9.1.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.3
@angular-devkit/build-angular 0.900.3
@angular-devkit/build-optimizer 0.900.3
@angular-devkit/build-webpack 0.900.3
@angular-devkit/core 9.0.5
@angular-devkit/schematics 9.0.5
@angular/cdk 9.1.1
@angular/cli 9.0.5
@angular/material 9.1.1
@ngtools/webpack 9.0.3
@nguniversal/builders 9.1.0
@nguniversal/common 9.1.0
@nguniversal/express-engine 9.1.0
@schematics/angular 9.0.5
@schematics/update 0.900.5
rxjs 6.5.4
typescript 3.7.5
webpack 4.41.2
Done in 0.45s.
Anything else relevant?
🐞 Bug report
Command (mark with an
x)Is this a regression?
No
Description
I'm implementing the
--localizeflag in our application build. We are serving our assets from a CDN, and so far we were building separate applications with--locale=..which was working fine, because we knew the locale and we could just specify--deployUrl=https://cdn.com/assets/${locale}.However now moving to
--localizeflag I can't do that anymore, because there's a single build for all locales.Actual problem
Since
localeis actually added to the--baseHref=/assets/formingthen I would almost expect the same thing to happen with
--deployUrlbecause I don't know that suffix a priori.Alternative solution
Another solution is constructing that path like
And in that case running
would return the proper localized asset path with the cdn
What I'm running
So currently my
ng buildlooks likeand while
baseHrefworks fine, thedeployUrlpoints at (for example) https://cdn.com/assets/main.js instead of https://cdn.com/assets/${locale}/main.js which ends up as HTTP 404.For the record in
app.module.tsI haveSimilar issues
I was reading some other issues and probably the closest one was #16625
but we can't grep/replace the assets because of our PWA configuration and hash checking the assets.
So is my approach wrong here? or is it actually a bug?
🔬 Minimal Reproduction
https://github.com/marcinowski/ng-build-localize-issue
$ yarn build --baseHref=/assets/ --deployUrl=https://cdn.com/assets/ --localize🔥 Exception or Error
🌍 Your Environment
Anything else relevant?