Search code examples
javascriptangulartypescriptangular-builder

Data path "/fileReplacements/1/replace" must match pattern "\.(([cm]?j|t)sx?|json)$". angular


I updated the angular from 10 to 14 and in the build i was using fileReplacements for favicon.ico replacement like this

"fileReplacements": [
     {
        "replace": "src/favicon.ico",
        "with": "src/images/my/favicon.ico"
     }
],

but this is showing error

Error: Schema validation failed with the following errors:
  Data path "/fileReplacements/1" must have required property 'src'.
  Data path "/fileReplacements/1/replace" must match pattern "\.(([cm]?j|t)sx?|json)$".
  Data path "/fileReplacements/1" must match exactly one schema in oneOf.

i tried in assets like this

"assets": [
      "src/favicon.ico",
      "src/assets",
      "src/web.config",
      "src/manifest.json",
      {
        "input": "src/favicon.ico",
        "output": "src/images/my/favicon.ico",
        "glob": "*.ico"
      },
      {
         "glob": "**/*",
         "input": "src/images/my",
         "output": "assets/images"
      }
   ]

but this shows

✖ Copying of assets failed.
Unable to copy assets: ENOTDIR invalid cwd E:/PROJECTS/myproj/src/favicon.ico

is there any solution for this?


Solution

  • For every environment, i have created a separate folder under builds like this In the assets in angular.json

    {
       "glob": "**/*",
       "input": "src/build/images-prod1",
       "output": "assets/images"
    }
    

    so in images-prod1 there is differnt favico file that will be copied in assets/images

    and in my index.html

    <link rel="icon" type="image/x-icon" href="assets/images/favicon.ico">
    

    so assets will copy different file based on build config and path is same