nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.35k stars 2.33k forks source link

build configuration fileReplacements not working #3486

Closed getanza closed 3 years ago

getanza commented 4 years ago

Hi,

The latest NX workspace seems to have an issue file replacements. Here is a github project (https://github.com/getanza/nx-file-replacements) to reproduce the problem.

` $ nx report

NX Report complete - copy this into the issue template

nx : Not Found @nrwl/angular : 10.0.9 @nrwl/cli : 10.0.9 @nrwl/cypress : 10.0.9 @nrwl/eslint-plugin-nx : Not Found @nrwl/express : Not Found @nrwl/jest : 10.0.9 @nrwl/linter : Not Found @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/react : Not Found @nrwl/schematics : Not Found @nrwl/tao : 10.0.9 @nrwl/web : Not Found @nrwl/workspace : 10.0.9 typescript : 3.9.7 `

  1. Steps use to created project is as below and in git commit messages.

$ npx create-nx-workspace@latest nx-file-replacements $ cd nx-file-replacements/ $ ng add @nrwl/angular $ ng generate @nrwl/angular:application --name=realworld ? Which stylesheet format would you like to use? CSS ? Would you like to configure routing for this application? No

  1. created two files $ cat apps/realworld/src/assets/config.json { "name": "not working!" } $ cat apps/realworld/src/assets/config.prod.json { "name": "YAY!" }

  2. Added the below fileReplacement config ... "configurations": { "production": { "fileReplacements": [ { "replace": "apps/realworld/src/assets/config.json", "with": "apps/realworld/src/assets/config.prod.json" }, { "replace": "apps/realworld/src/environments/environment.ts", "with": "apps/realworld/src/environments/environment.prod.ts" } ], ...

  3. diff the output $ nx build realworld --prod $ diff dist/apps/realworld/assets/config.json dist/apps/realworld/assets/config.prod.json 2c2 < "name": "not working!" --- > "name": "YAY!"

Stupidism commented 4 years ago

I think the problem is the assets folder is overwrited by the assets option

getanza commented 4 years ago

I think the problem is the assets folder is overwrited by the assets option

That's interesting, I've been able to successfully use this config for a different project (Angular) in an older version (8.7.0).

I should also add that I discovered this issue, after (being really excited) reading this blog post (https://blog.nrwl.io/migrating-an-angularjs-project-into-an-nx-workspace-d329d907f48). I've been largely successful with merging 5 AngularJS projects into a monorepo.

The only problem is when I basically copied the file replacement config from my Angular project (nx report below) into this new AngularJS mono repo. The main difference I can see is that I'm using the "builder": "@nrwl/web:build", in the new one (from blog post).

So I'm a little confused at the moment about whether or not I'm supposed to expect this behaviour to be there or not? Or do let me know if what I did in my 8.7.0 nx project.

$ nx report

NX Report complete - copy this into the issue template

@nrwl/angular : 8.7.0 @nrwl/cli : 8.7.0 @nrwl/cypress : 8.7.0 @nrwl/eslint-plugin-nx : Not Found @nrwl/express : Not Found @nrwl/jest : 8.7.0 @nrwl/linter : Not Found @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/react : Not Found @nrwl/schematics : Not Found @nrwl/tao : 8.7.0 @nrwl/web : Not Found @nrwl/workspace : 8.7.0 typescript : 3.4.5

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.