微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

angular 6,build无法在Firebase托管上加载图片

将angular应用程序部署到firebase托管后,我无法从assets文件夹加载图像. (build –prod)
当在localhost上运行时,图像显示.
所有其他东西都正确加载.
这是我的包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上尝试过

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

这一切都没有.

在firebase.json托管设置

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

}

在firebase上有一些技巧吗?重写?有人可以帮助我!

解决方法

在firebase部署之后,现在从角度6.1.3中的资产加载图像!终于找到了解决方案,它对我有用.问题是tsconfig.json更改:

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

至:

"outDir": "./dist",

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐