角度6,构建无法在Firebase托管上加载图像 [英] angular 6, build can't load images on Firebase hosting

查看:67
本文介绍了角度6,构建无法在Firebase托管上加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将角度应用部署到Firebase托管后,我无法从资产文件夹中加载图像。 (build --prod)
在图像显示的本地主机上运行时。
所有其他东西都正确加载。
这是我的软件包json
cli:〜6.2.0-beta.2
firebase-tools:4.1.0

I'm unable to load images from the assets folder after deploy the angular app to firebase hosting. (build --prod) when run on localhost the images show. All other things are loading properly. this is my package json cli: ~6.2.0-beta.2 firebase-tools: 4.1.0

{
  "name": "protocols",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "deploy": "ng build --prod && firebase deploy"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.2",
    "@angular/cdk": "^6.4.5",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/forms": "^6.1.0",
    "@angular/http": "^6.1.0",
    "@angular/material": "^6.4.5",
    "@angular/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/pwa": "^0.8.0-beta.2",
    "@angular/router": "^6.1.0",
    "@angular/service-worker": "^6.1.0",
    "angularfire2": "^5.0.0-rc.11",
    "core-js": "^2.5.4",
    "firebase": "^5.3.1",
    "hammerjs": "^2.0.8",
    "mat-progress-buttons": "^6.0.1",
    "rxjs": "^6.0.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.8.0-beta.0",
    "@angular/cli": "~6.2.0-beta.2",
    "@angular/compiler-cli": "^6.1.0",
    "@angular/language-service": "^6.1.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.3.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~2.9.2"
  }
}

在appComponent上尝试过

tried at appComponent

<img src="../assets/image.jpg">
<img src="/assets/image.jpg">
<img src="assets/image.jpg">

没有这项工作。

托管firebase.json中的设置

hosting settings at firebase.json

"hosting": {
"public": "dist",
"ignore": [
  "firebase.json",
  "**/.*",
  "**/node_modules/**"
],
"rewrites": [
  {
    "source": "**",
    "destination": "/index.html"
  }
]

}

火力基地有招吗?重写?有人可以帮我!

Are there some trick on the firebase? rewrites? someone can help me!

推荐答案

Firebase部署后,现在正在从角6.1.3中的资产加载图像!终于找到了解决方案,对我来说很好。问题是tsconfig.json更改:

Images loading now from assets in angular 6.1.3 after firebase deploy! Found the solution finally, well it works for me. The issue is the tsconfig.json change:

"outDir": "./dist/out-tsc",

到:

"outDir": "./dist",

这篇关于角度6,构建无法在Firebase托管上加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆