Дисплеи развертывания Firebase Экран приветствия без содержимого приложения Дисплеи развертывания Firebase - PullRequest
0 голосов
/ 21 октября 2018

Я столкнулся с проблемой с моим угловым приложением (6.0.0), когда я пытался развернуть его на firbase.

Оно показывает «Страница приветствия Firebase Welcome всегда».Я читаю все блоги, которые уже опубликованы с той же проблемой и следую тем же инструкциям, которые они предложили.Тем не менее, я не могу отобразить страницу приложения, хотя я заменил файл index.html на папку dist index.html.Я не знаю, откуда эта «Страница приветствия Firebase».Я потратил почти 2 дня, чтобы найти решение, но не смог.

Не могли бы вы помочь в этом отношении.

Спасибо

Файл моего проекта Json: -

{
  "name": "myproject",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.0",
    "@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/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/router": "^6.1.0",
    "@ng-bootstrap/ng-bootstrap": "^3.3.1",
    "angularfire2": "^5.0.0-rc.6",
    "bootstrap": "^4.1.3",
    "core-js": "^2.5.4",
    "firebase": "^4.12.1",
    "firebase-tools": "^5.1.1",
    "g": "^2.0.1",
    "ngx-bootstrap": "^3.0.1",
    "rxjs": "~6.2.0",
    "rxjs-compat": "^6.3.3",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.8.0",
    "@angular/cli": "~6.2.4",
    "@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": "~3.0.0",
    "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"
  }
}

firebase json

**I just mention here my steps to deploy:-**

C:\Users\User\Desktop\hello-world>firebase login
Already logged in as subratamitra2011@gmail.com
C:\Users\User\Desktop\hello-world>firebase init

 ######## #### ########  ######## ########     ###     ######  ########
 ##        ##  ##     ## ##       ##     ##  ##   ##  ##       ##
 ######    ##  ########  ######   ########  #########  ######  ######
 ##        ##  ##    ##  ##       ##     ## ##     ##       ## ##
 ##       #### ##     ## ######## ########  ##     ##  ######  ########
You're about to initialize a Firebase project in this directory:
C:\Users\User\Desktop\hello-world
? Are you ready to proceed? Yes
? Which Firebase CLI features do you want to setup for this folder? Press Space to select features, then Enter to confirm your choices. Hosting: Configure and deploy Firebase Hosting sites
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
? Select a default Firebase project for this directory: helloworld-591c4 (helloworld)
i Using project helloworld-591c4 (helloworld)
=== Hosting Setup
Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.
? What do you want to use as your public directory? dist
? Configure as a single-page app (rewrite all urls to /index.html)? No
+ Wrote dist/404.html
+ Wrote dist/index.html
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
Firebase initialization complete!
C:\Users\User\Desktop\hello-world>ng build --prod
Date: 2018-10-22T04:10:50.394Z
Hash: d2fabf219965cc523f24
Time: 19752ms
chunk {0} runtime.ec2944dd8b20ec099bf3.js (runtime) 1.44 kB [entry] [rendered]
chunk {1} main.9127db5a4ec3dfb85364.js (main) 746 kB [initial] [rendered]
chunk {2} polyfills.9d02003b6ccac27ce6ad.js (polyfills) 64.3 kB [initial] [rendered]
chunk {3} styles.cc25d04069d157e07245.css (styles) 128 kB [initial] [rendered]
C:\Users\User\Desktop\hello-world>firebase deploy
=== Deploying to 'helloworld-591c4'...
i deploying hosting
i hosting[helloworld-591c4]: beginning deploy...
i hosting[helloworld-591c4]: found 9 files in dist
+ hosting[helloworld-591c4]: file upload complete
i hosting[helloworld-591c4]: finalizing version...
+ hosting[helloworld-591c4]: version finalized
i hosting[helloworld-591c4]: releasing new version...
+ hosting[helloworld-591c4]: release complete
Deploy complete!
Project Console: https://console.firebase.google.com/project/helloworld-591c4/overview
Hosting URL: https://helloworld-591c4.firebaseapp.com

Теперь с этим URL отображается страница по умолчанию из-за этого: -

https://imgur.com/a/CnREqUQ

Затем я изменяю dist / index.html с моим проектом index.html и соберите заново

Это мой проект Index.html: - https://imgur.com/a/rvvjIXZ

   

<!-- begin snippet: js hide: false console: true babel: false -->

DIST / MYPROJECT / INDEX.HTML https://imgur.com/a/LebwZ0h

Теперь у меня есть пустая страница с этим URL.Не могли бы вы помочь выяснить мои ошибки.Спасибо, с уважением, Субрата Митра`

Ответы [ 3 ]

0 голосов
/ 04 ноября 2018

Моя проблема в этом случае заключалась в том, что «развертывание firebase» получало файлы в общей папке, как указано при выполнении первой инициализации.Тем не менее, с помощью реагирования ваш статический сайт создается в другой папке (в моем случае «build»)

Так что, согласно сообщению Родивы, вы должны повторно запустить «firebase init» и указать папку, которую вы хотите загрузить.

0 голосов
/ 12 декабря 2018

Если ваша папка dist содержит папку с названием вашего приложения, измените firebase.json:
"public": "dist", на "public": "dist/MyApp",

Пример:
Если ваше приложениеназывается "ShoppingList".Ваш firebase.json должен выглядеть так:

{
 "hosting": {
  "public": "dist/ShoppingList",
  "ignore": [
   "firebase.json",
   "**/.*",
   "**/node_modules/**"
  ],
 "rewrites": [
   {
     "source": "**",
     "destination": "/index.html"
   }
  ]
 }
}
0 голосов
/ 22 октября 2018

У меня была похожая проблема, когда я развертывал проект React (Create React App) с использованием firebase.Проблема с моей стороны заключалась в том, что при первоначальной настройке firebase init я использовал имя папки сборки по умолчанию, предоставляемое firebase - /public.Но, как оказалось, всякий раз, когда я использовал для сборки свой проект, он собирался в другую папку /build.Поэтому я снова запустил firebase init и на этот раз указал папку build.

Итак, вы можете проверить, правильно ли указана папка, в которую вы строите.

Кроме того, вы также build разрабатываете свой проект перед развертыванием?

ОБНОВЛЕНИЕ - Если вы предпочитаете использовать dist в качестве папки сборки, настройте firebase таким образом.

  1. Запустите firebase init еще раз.
  2. В одном изшаги, он спросит вас, если вы хотите переименовать папку сборки.По умолчанию public.Здесь введите dist и нажмите enter.
  3. Завершите остальные шаги firebase init.
  4. Создайте свой проект заново.
  5. Выполните firebase deploy.enter image description here

Теперь попробуйте запустить свой веб-сайт по URL-адресу, предоставленному firebase в терминале.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...