Skip to content

Something changed in fileReplacements and assets with Angular 9 #16779

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

Closed
14 tasks
Kunepro opened this issue Jan 28, 2020 · 4 comments
Closed
14 tasks

Something changed in fileReplacements and assets with Angular 9 #16779

Kunepro opened this issue Jan 28, 2020 · 4 comments

Comments

@Kunepro
Copy link

Kunepro commented Jan 28, 2020

🐞 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?

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Jan 28, 2020

Hi, this used to work unintentionalaly as fileReplacements was not meant to replace files which are outside of the bundles. See: #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: #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"
  }
],

@Kunepro
Copy link
Author

Kunepro commented Jan 28, 2020

Thank you, I will use the approach you suggested.

@alan-agius4
Copy link
Collaborator

Closing as this feature is working as per design.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants