One project, multiple sites! Plus a boost in upload speed!

栏目: C++ · 发布时间: 6年前

内容简介:Do you manage multiple Firebase Hosting sites? Do these sites share a single resource like a Firestore or Realtime database? Do you wish you could manage these sites from one place instead of having to create multiple projects? Do you wish that Firebase H
One project, multiple sites! Plus a boost in upload speed!

Diana Tkachenko

Software Engineer

One project, multiple sites! Plus a boost in upload speed!

Alex Memering

Software Engineer

Do you manage multiple Firebase Hosting sites? Do these sites share a single resource like a Firestore or Realtime database? Do you wish you could manage these sites from one place instead of having to create multiple projects? Do you wish that Firebase Hosting could deploy only the new or modified files? Wish no more! Because it’s all here!

Create multiple sites in one project

Firebase Hosting now allows you to create multiple sites inside of one Firebase project. If your admin site and blog site consume data from a shared Firebase resource, they can now both live in a single project – saving you time and developer resources. You can manage these sites directly in the Firebase Console and deploy via the command line.

One project, multiple sites! Plus a boost in upload speed!

Firebase automatically provisions a firebaseapp domain for you, which is the same as your Firebase project name. We currently do not support subdomains on the firebaseapp.com domain, but you can still provision subdomains on your own by connecting a custom domain for your sites. To get started with multiple sites, you’ll need to be on the Blaze plan . Once you’re on the Blaze plan you’ll be able to add multiple sites inside of the Firebase Console.

One project, multiple sites! Plus a boost in upload speed!

Configure targets for multiple sites in firebase.json

To help switch between different sites in a single project we introduced a new configuration setup in firebase.json . Make sure you update to the latest version of the Firebase CLI!

{
  "hosting": [ {
      "target": "blog",
      "public": "blog/dist"
    }, {
      "target": "app",
      "public": "app/dist"
    }
  ]}

The "hosting" config can now take in an array of site configurations. A single object still works if you still have just one site. Each configuration has a "target" . The CLI uses this target to know what "public" folder to use for deploying assets. Speaking of the CLI! We have a new command for you.

Deploy from the CLI with targets

To manage switching between multiple sites in one project, we’re going to use the target:apply command. This command is a bit like the firebase use --add command except instead of linking the project to the alias, it establishes a link between the site and the target. The applied target can then be used with the firebase deploy and firebase serve commands.

The firebase use command is helpful for deploying to multiple projects. This is common for those who have a “staging” project versus a “production” project. For managing one site across different environments, we still recommend multiple projects for promoting best practices of each environment having its own set of Firebase resources.

However, managing multiple sites is a different problem. The CLI now has to know about multiple sites instead of just one. The CLI must know:

  • The name of the specific site
  • Where the assets of this site are located
  • What project you wish to deploy this site to

This why we introduced target:apply for Hosting.

firebase target:apply hosting target-name site-name

Let’s break down this command.

  • firebase – the Firebase CLI module
  • target:apply – the command to link the site to the target
  • hosting – the Firebase resource type of the target
  • target-name – the target name specified in firebase.json . You could use "blog" or "app" as in the example config above.
  • site-name – the name of the site you want the target associated with

Let’s say you wanted to deploy your blog using the example firebase.json above:

firebase target:apply hosting blog my-cool-blog
firebase deploy blog

In this command, we first identified the target-name of "blog" , then associated it with the targeted site “my-cool-blog”, and finally deployed to that target. If you don’t specify a target in your firebase deploy or firebase serve commands, then all your targets will be deployed, or served locally on different ports, respectively. Note that you only have to define your targets once per project.

Your uploads just got a bit faster, and in some cases a lot faster

If you updated the Firebase CLI recently, you might have noticed that your uploads got a bit faster. You may have also noticed a new .firebase folder in your project. That’s because we rolled up a new deployment system that we call Delta Uploads.

This new system only processes new, modified, or deleted files. You know, the delta. This means any files that are unchanged aren’t uploaded when you run firebase deploy . You may not notice a big improvement in performance if your site is only a few files. However, it will make a huge difference for sites with a large amount of existing unmodified assets.

Give it a try today!

Check out the official documentation and make sure to update your CLI! Both multi-site and delta uploads features require the latest version of the Firebase CLI. Make sure you’re either above or at version 4.2.0 to use these features. Happy deploying!

除非特别声明,此文章内容采用 知识共享署名 3.0 许可,代码示例采用 Apache 2.0 许可。更多细节请查看我们的 服务条款


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

C++语言的设计和演化

C++语言的设计和演化

[美] Bjarne Stroustrup / 裘宗燕 / 机械工业出版社 / 2002-1 / 48.00元

这本书是C++的设计者关于C++语言的最主要著作之一。作者综合性地论述了C++的历史和发展,C++中各种重要机制的本质意义和设计背景,这些机制的基本用途和使用方法,讨论了C++所适合的应用领域及其未来的发展前景。一起来看看 《C++语言的设计和演化》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具