0

I have my app developed in StackBlitz, and incldued with ngx-translate package. It is working perfectly until it deployed to firebase.... basically everything broken (sobbing...) I tried my best to detail out my configs and the error log as i couldn't resolve it myself. I also dig through the internet but no luck to resolve any of them. Sorry for the lengthy post.

index.html

<link rel="stylesheet" type="text/css" href="/node_modules/primeicons/primeicons.css" />
<link rel="stylesheet" type="text/css" href="/node_modules/primeng/resources/themes/nova-light/theme.css" />
<link rel="stylesheet" type="text/css" href="/node_modules/primeng/resources/primeng.min.css" />

The above code error out in Firebase but not StackBlitz (run perfectly)

Resource interpreted as Stylesheet but transferred with MIME type text/html: "https://fireforgez.firebaseapp.com/node_modules/primeng/resources/themes/nova-light/theme.css".
Resource interpreted as Stylesheet but transferred with MIME type text/html: "https://fireforgez.firebaseapp.com/node_modules/primeng/resources/primeng.min.css".
Resource interpreted as Stylesheet but transferred with MIME type text/html: "https://fireforgez.firebaseapp.com/node_modules/primeicons/primeicons.css".

To get rid of it, i did a silly patch by replace it with actual web URL

<link rel="stylesheet" type="text/css" href="https://unpkg.com/primeicons@4.0.0-rc.2/primeicons.css" />
<link rel="stylesheet" type="text/css" href="https://unpkg.com/primeng@9.1.0/resources/themes/nova-light/theme.css" />
<link rel="stylesheet" type="text/css" href="https://unpkg.com/primeng@9.1.0/resources/primeng.min.css" />

PrimeFlex package also hit the similar error

    DevTools failed to load SourceMap: Could not parse content for
https://fireforgez.firebaseapp.com/primeflex.css.map: Unexpected token < in JSON at position 0

I compared both StackBlitz and Firebase, the stylesheet files are all load-able. But when i replace with firebase hosting url, all .css revert back to firebase main url e.g. https://fireforgez.firebaseapp.com/node_modules/primeng/resources/themes/nova-light/theme.css will redirect to https://fireforgez.firebaseapp.com/ and generated a series of error

Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'node_modules/primeng/resources/themes/nova-light/theme.css'
Error: Cannot match any routes. URL Segment: 'node_modules/primeng/resources/themes/nova-light/theme.css'
    at ApplyRedirects.noMatchError (router.umd.js:2284) [angular]
    at CatchSubscriber.eval [as selector] (router.umd.js:2265) [angular]
    at CatchSubscriber.error (catchError.js:48) [angular]
    at MapSubscriber.Subscriber._error (Subscriber.js:92) [angular]
    at MapSubscriber.Subscriber.error (Subscriber.js:72) [angular]
    at MapSubscriber.Subscriber._error (Subscriber.js:92) [angular]
    at MapSubscriber.Subscriber.error (Subscriber.js:72) [angular]
    at MapSubscriber.Subscriber._error (Subscriber.js:92) [angular]
    at MapSubscriber.Subscriber.error (Subscriber.js:72) [angular]
    at ThrowIfEmptySubscriber.Subscriber._error (Subscriber.js:92) [angular]
    at ThrowIfEmptySubscriber.Subscriber.error (Subscriber.js:72) [angular]
    at TakeLastSubscriber.Subscriber._error (Subscriber.js:92) [angular]
    at TakeLastSubscriber.Subscriber.error (Subscriber.js:72) [angular]
    at MergeMapSubscriber.OuterSubscriber.notifyError (OuterSubscriber.js:26) [angular]
    at resolvePromise (zone.js:816) [angular]
    at resolvePromise (zone.js:768) [angular]
    at eval (zone.js:878) [angular]
    at Object.onInvokeTask (core.umd.js:19397) [angular]
    at drainMicroTaskQueue (zone.js:591) [<root>]

For ngx-translate, it's also working correctly in StackBlitz but couldn't load language files.

SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at XMLHttpRequest.onLoad (https://fireforgez.firebaseapp.com/turbo_modules/@angular/common@9.1.9/bundles/common-http.umd.js:1390:55)
at ZoneDelegate.invokeTask (https://fireforgez.firebaseapp.com/turbo_modules/zone.js@0.10.3/dist/zone.js:411:35)
at Object.onInvokeTask (https://fireforgez.firebaseapp.com/turbo_modules/@angular/core@9.1.9/bundles/core.umd.js:19397:37)
at ZoneDelegate.invokeTask (https://fireforgez.firebaseapp.com/turbo_modules/zone.js@0.10.3/dist/zone.js:410:40)
at Zone.runTask (https://fireforgez.firebaseapp.com/turbo_modules/zone.js@0.10.3/dist/zone.js:178:51)
at ZoneTask.invokeTask [as invoke] (https://fireforgez.firebaseapp.com/turbo_modules/zone.js@0.10.3/dist/zone.js:493:38)
at invokeTask (https://fireforgez.firebaseapp.com/turbo_modules/zone.js@0.10.3/dist/zone.js:1633:18)
at XMLHttpRequest.globalZoneAwareCallback (https://fireforgez.firebaseapp.com/turbo_modules/zone.js@0.10.3/dist/zone.js:1670:25)
...
message: "Http failure during parsing for https://fireforgez.firebaseapp.com/assets/i18n/en.json"
name: "HttpErrorResponse"
ok: false
status: 200
statusText: "OK"
url: "https://fireforgez.firebaseapp.com/assets/i18n/en.json"

Here i my complete angular.json file

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "demo": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/demo",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css",
              "node_modules/primeicons/primeicons.css",
              "node_modules/primeng/resources/themes/nova-light/theme.css",
              "node_modules/primeng/resources/primeng.min.css",
              "../node_modules/quill/dist/quill.core.css",
              "../node_modules/quill/dist/quill.snow.css",
              "node_modules/primeflex/primeflex.css"
            ],
            "scripts": [
              "../node_modules/quill/dist/quill.js"
            ]
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "demo:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "demo:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "demo:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "styles": [
              "styles.css"
            ],
            "scripts": [
              "../node_modules/quill/dist/quill.js"
            ],
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "demo"
}
Weilies
  • 500
  • 1
  • 7
  • 27

1 Answers1

0

I very appreciate Eric, who is the owner of StackBlitz being so grateful and patient to explained that the Firebase deployment still in Beta (i didn't aware before that!...) https://github.com/stackblitz/core/issues/1254#issuecomment-636860107

I keep trying every possible ways to solve it in SB for deployment but no luck. With his advise, i crack my head and bring down the project to local, and manually build the broken dependencies in local. After that i deployed to firebase and everything is now WORKING!

So for the time being, if you guys having serious projects and need to deploy from SB to Firebase, i advise you to wait until the deployment got a stable release.

Weilies
  • 500
  • 1
  • 7
  • 27