angularjstypescriptfirebase-hosting

Error: Assertion failed: resolving hosting target of a site with no site name or target name -> Deploying change in Firebase Hosting to Live site


{
  "database": {
    "rules": "database.rules.json"
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "hosting": [
    {
      "public": "dist/nur",
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    },
    {
      "target": "nur",
      "public": "dist/nur",
      "ignore": [
        "**/.*"
      ],
      "headers": [
        {
          "source": "*.[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].+(css|js)",
          "headers": [
            {
              "key": "Cache-Control",
              "value": "public,max-age=31536000,immutable"
            }
          ]
        },
        {
          "source": "/@(ngsw-worker.js|ngsw.json)",
          "headers": [
            {
              "key": "Cache-Control",
              "value": "no-cache"
            }
          ]
        }
      ],
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    }
  ],
  "storage": {
    "rules": "storage.rules"
  }
}


Tried firebase deploy command through Firebase to deploy the changes.

Deploying to 'nur-beta'...

i  deploying database, storage, firestore, hosting
i  database: checking rules syntax...
database: rules syntax for database nur-beta-default-rtdb is valid
i  firebase.storage: checking storage.rules for compilation errors...
firebase.storage: rules file storage.rules compiled successfully
i  firestore: reading indexes from firestore.indexes.json...
i  cloud.firestore: checking firestore.rules for compilation errors...
cloud.firestore: rules file firestore.rules compiled successfully

After all resources deployement it gives assertion failed message.

Error: Assertion failed: resolving hosting target of a site with no site name or target name. This should have caused an error earlier. May I know what I'm missing while deploying the changes to already LIVE web-site hosted under Firebase Hosting.


Solution

  • There is no problem with your JSON file.

    For deployment to firebase hosting first of all you have to build your project then you push your project to firebase hosting

    command to build the project and deploy it to firebase

    1. For angular use the ng build command in the terminal of your project location.
    2. after building run the firebase deploy command
    3. See the Magic