Something changed in fileReplacements and assets with Angular 9
🐞 Bug report
Command (mark with an x)
- [ ] new
- [x ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Is this a regression?
Yes, the pipeline to build/deploy was working in Angular 8.2, the behaviour changed migrating to Angular 9.rc10
Description
The way that angular.json configuration for "fileReplacements" and "assets" works has changed.
🔬 Minimal Reproduction
To deploy with CloudFoundry I need to provide an environment specific manifest.yml file. So I have a manifest.{env}.yml for each environment.
In 8.2, I was specifying to replace the manifest file with "fileReplacements", and then adding the manifest.yml as an "asset" to push to CloudFoundry.
For example for the environment "staging" I would have: /src/deployment/manifest.staging.yml /src/deployment/manifest.yml
The first step here would be fileReplacements kicking in, moving the content from manifest.staging.yml inside manifest.yml
The second/last step is manifest.yml being included in dist through the "assets" configuration, but with the staging's configuration inside.
Instead, after migrating to Angular 9.rc10, fileReplacements doesn't happen in time and manifest.yml has the content of the original (non-staging) one.
As a possible fix I tried this approach: I tried to change my assets configuration to grab directly the manifest file: { "glob": "manifest.staging.yml", "input": "apps/appointment-manager/src/deployment", "output": "manifest.yml" },
I expected: dist/manifest.yml Instead I got: dist/manifest.yml/manifest.staging.yml
the output was read as a directory where to place the content.
🔥 Exception or Error
Nope.
🌍 Your Environment
Angular CLI: 9.0.0-rc.10
Node: 12.4.0
OS: win32 x64
Angular: 9.0.0-rc.10
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.0-rc.10
@angular-devkit/build-angular 0.900.0-rc.10
@angular-devkit/build-optimizer 0.900.0-rc.10
@angular-devkit/build-webpack 0.900.0-rc.10
@angular-devkit/core 9.0.0-rc.10
@angular-devkit/schematics 8.3.23
@angular/cdk 9.0.0-rc.8
@ngtools/webpack 9.0.0-rc.10
@schematics/angular 8.3.14
@schematics/update 0.900.0-rc.10
rxjs 6.5.4
typescript 3.7.5
webpack 4.41.2
Anything else relevant?
Hi, this used to work unintentionalaly as fileReplacements was not meant to replace files which are outside of the bundles. See: https://github.com/angular/angular-cli/issues/16439
The output is used to specify the absolute path (directory) within the output where assets should be emitted. Currently file renaming is also not support and there is a feature request for this: https://github.com/angular/angular-cli/issues/8808
The way this can be done is by having the configuration files in separate folders and setting the assets option as follows and configure different assets for each environment.
"assets": [
"src/favicon.ico",
"src/assets",
{
"input": "src/deployment/staging",
"output": "/",
"glob": "*.yml"
}
],
Thank you, I will use the approach you suggested.
Closing as this feature is working as per design.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.