Firebase Hosting Tutorial #4 - Deploying a Vue Site

Net Ninja · Beginner ·🛠️ AI Tools & Apps ·7y ago

Key Takeaways

Deploys a Vue.js website to Firebase Hosting

Full Transcript

all right there so now we've seen how to deploy a static website to firebase hosting now I'd like to show you how to deploy something slightly different a single page application now we can create a single page application or an SP a with something like react or angular or view I've chosen to use of UJS and the way we deploy these to firebase is ever so slightly different not much but ever so slightly so I've already used view GS to create this project right here mário code club and this is where I am in the terminal down at the bottom now I did this I just basically same view create and then the name of the application mario code club and it generated this boilerplate project for me with all these different folders and files now I don't want to get bogged down too much with view Jas and how to use view if you want to learn all about that then I do have a completely free tutorial series here on YouTube view Jas for beginners so I'll leave that link down below and you also have a udemy course which goes into view Jas and firebase in-depth as well but anyway just very quickly inside the router J's file we can see I have two different routes set up one for the home page just forward slash and one for about I also have the mode set to history so we don't see those little hashes inside the URLs now the way a single page application works is that we always serve up a single index dot HTML file that's the only thing that's ever served to the browser and then JavaScript takes over and when we visit a certain URL then we still serve up that single index page and dependent on the URL we load a different component into that page now this is important because when we come to initialize our firebase project shortly we're going to set up an option so that firebase always sends back the index file to the browser regardless of what URL we visit okay so we have two different routes hit home and about and I can open those up inside views so we have the home page right here and we have the about page right here very very simple it's just a boilerplate project and I've just changed the colors and the text a little bit so anyway that is our view project now the first thing we need to do is initialize a fire based project inside this directory Meriel code club so make sure you're in the right directory and then we say firebase in it or like so now again this is going to ask us a couple of different questions first of all are you ready to proceed yep and then what do we want to use we want to use the hosting press ENTER now we want to apply it to the firebase hosting ninja project on the back end so we're going to overwrite the stuff that we've previously deployed so I'm going to select this one now what do you want as your public directory now previously we left this as default which is public and remember that was the folder that firebase then generated and then we deployed it to firebase now if you notice over here we already have a public folder and view j/s uses this for something else now when we build a view j/s project it builds it into a dist folder and that dist folder is the thing that then we're meant to deploy so I'm going to change the public directory down here for firebase to dist so when we use firebase deploy it's going to look for the dist folder and deploy that instead of the default value of public so I'm going to press ENTER now now configure it as a single page application rewrite all URLs to indexed or HTML well this time we want to select yes now when we created a static website we said no because we don't just want to send everyone to index dot HTML regardless of what URL they visit we want to load up the correct page but now since we're using a single page application using view or it could be react or it could be angular now we only ever want to serve up index.html because then JavaScript takes over and it loads in the components that we want to show but we always civil the same index dot HTML so this is going to take care of the server-side configuration to do this for us so this time we press yes and then enter and that is it we've initialized this project now so we can see now we have this file firebase are see also firebase Jason down here and we have get ignore as well we can also see this dist folder over here with indexed or HTML inside it now notice now we don't have a 404 page because this has been configured as a single page application so even if they go to forward slash something-or-other that doesn't exist it's still gonna route them to the index page and then javascript takes over so now we would configure our 404 inside of UJS itself not in this disk folder as a separate file so anyway this is the dummy index page now we don't want to deploy this we now want to build our view application so that all the files go inside this dist folder and then we want to deploy it so let me cross this off down here I'm just gonna say Claire to give us a bit of room then I'm gonna say NPM run build this is what we use to build our view application so press ENTER that's just gonna take a few seconds to do ok now that's done an inside disk now we should see some different things now we see the CSS for our project the JavaScript and we also see a new index file so let's just preview this before we actually deploy so I'm gonna say firebase serve now and now because we specified before that we want to use the dist folder instead of public it's going to serve up whatever is inside disk and it says that we'll write down here so let's view this in a browser I'm going to just control click over here and now we can see this application if we click on about it goes to /a bount we're still serving up the index page because we've configured this as a single page application but now we get this different component loaded in so that's the preview everything's looking good now we want to deploy it to firebase so let's do that over here I'm going to cancel out of this project by pressing ctrl C terminate yes and now we want to deploy this project now to do that remember we say firebase deploy like so and that will deploy this folder to firebase right here alright then so now that's done let's come over to our project on the backend and flesh and fingers crossed let's hope this works we should see another deployment over here when it eventually loads and we can see now April 11th 6 p.m. which is 2 hours later that I did the other video so now we can see this new deployment and if we open this up in a browser then we should see this new application and we can do and notice even though we're going to different URLs we're still getting the same HTML page back there's no loading time here it's not serving up and about dot HTML page it's always index dot HTML and even if I go to something like this it's going to serve up index dot HTML now we don't see any component loaded here we just see the nav because our view project isn't correctly set up to handle these different 404 cases but it's still serving up the same index file and that's why that option was so important when it said configure this as a single page application and the same would apply if it was react or angular or some other kind of framework so there we go my friends that's how we deploy a single page application to firebase in the next video I'm going to go through some final configuration options and also show you how to set up some redirects as well

Original Description

Learn how to deploy your websites to Firebase! In this tutorial I'll show you how to deploy a Vue.js website to Firebase hosting. ---------------------------------------- 🐱‍💻 🐱‍💻 Course Links: Firebase - https://firebase.google.com/ 🐱‍💻 🐱‍💻 Other Relater Courses: Firebase Authentication Tutorial - https://www.youtube.com/watch?v=aN1LnNq4z54&list=PL4cUxeGkcC9jUPIes_B8vRjn1_GaplOPQ Firebase Firestore Tutorial - https://www.youtube.com/watch?v=4d-gIPGzmK4&list=PL4cUxeGkcC9itfjle0ji1xOZ2cjRGY_WB
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 0 of 60

← Previous Next →
1 Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
2 Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
3 Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
4 GraphQL Tutorial #1 - Introduction to GraphQL
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
5 GraphQL Tutorial #2 - A Birdseye View of GraphQL
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
6 GraphQL Tutorial #3 - Project (stack) Overview
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
7 GraphQL Tutorial #4 - Making Queries (front-end preview)
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
8 GraphQL Tutorial #5 - Express App Setup
GraphQL Tutorial #5 - Express App Setup
Net Ninja
9 GraphQL Tutorial #6 - Setting up GraphQL
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
10 GraphQL Tutorial #7 - GraphQL Schema
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
11 GraphQL Tutorial #8 - Root Query
GraphQL Tutorial #8 - Root Query
Net Ninja
12 GraphQL Tutorial #9 - The Resolve Function
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
13 GraphQL Tutorial #10 - Testing Queries in Graphiql
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
14 GraphQL Tutorial #11 - GraphQL ID Type
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
15 GraphQL Tutorial #12 - Author Type
GraphQL Tutorial #12 - Author Type
Net Ninja
16 GraphQL Tutorial #13 - Type Relations
GraphQL Tutorial #13 - Type Relations
Net Ninja
17 GraphQL Tutorial #14 - GraphQL Lists
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
18 GraphQL Tutorial #15 - More on Root Queries
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
19 GraphQL Tutorial #16 - Connecting to mLab
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
20 GraphQL Tutorial #17 - Mongoose Models
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
21 GraphQL Tutorial #18 - Mutations
GraphQL Tutorial #18 - Mutations
Net Ninja
22 GraphQL Tutorial #19 - More on Mutations
GraphQL Tutorial #19 - More on Mutations
Net Ninja
23 GraphQL Tutorial #20 - Updating the Resolve Functions
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
24 GraphQL Tutorial #21 - GraphQL NonNull
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
25 GraphQL Tutorial #22 - Adding a Front-end
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
26 GraphQL Tutorial #23 - Create React App
GraphQL Tutorial #23 - Create React App
Net Ninja
27 GraphQL Tutorial #24 - Book List Component
GraphQL Tutorial #24 - Book List Component
Net Ninja
28 GraphQL Tutorial #25 - Apollo Client Setup
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
29 GraphQL Tutorial #26 - Making Queries from React
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
30 GraphQL Tutorial #27 - Rendering Data in a Component
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
31 GraphQL Tutorial #28 - Add Book Component
GraphQL Tutorial #28 - Add Book Component
Net Ninja
32 GraphQL Tutorial #29 - External Query File
GraphQL Tutorial #29 - External Query File
Net Ninja
33 GraphQL Tutorial #30 - Updating Component State
GraphQL Tutorial #30 - Updating Component State
Net Ninja
34 GraphQL Tutorial #31 - Composing Queries
GraphQL Tutorial #31 - Composing Queries
Net Ninja
35 GraphQL Tutorial #32 - query variables
GraphQL Tutorial #32 - query variables
Net Ninja
36 GraphQL Tutorial #33 - Re-fetching Queries
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
37 GraphQL Tutorial #34 - Book Details Component
GraphQL Tutorial #34 - Book Details Component
Net Ninja
38 GraphQL Tutorial #36 - Styling the App
GraphQL Tutorial #36 - Styling the App
Net Ninja
39 GraphQL Tutorial #35 - Making a Single Query
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
40 Build Apps with Vue & Firebase - Udemy Course
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
41 Updated Vue & Firebase Course (Udemy)
Updated Vue & Firebase Course (Udemy)
Net Ninja
42 Vue & Firebase Real-time Chat (Preview) #1 - Intro
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
43 Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
44 Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
45 Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
46 Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
47 Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
48 Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
49 Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
50 Object Oriented JavaScript Tutorial #1 - Introduction
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
51 Object Oriented JavaScript Tutorial #2 - Object Literals
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
52 Object Oriented JavaScript Tutorial #3 - Updating Properties
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
53 Object Oriented JavaScript Tutorial #4 - Classes
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
54 Object Oriented JavaScript Tutorial #5  - Class Constructors
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
55 Object Oriented JavaScript Tutorial #6 - Class Methods
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
56 Object Oriented JavaScript Tutorial #7 - Method Chaining
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
57 Object Oriented JavaScript Tutorial #8 - Class Inheritance
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
58 Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
59 Object Oriented JavaScript Tutorial #10 - Prototype
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
60 Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja

Related Reads

📰
Three Token-2022 Mints in One Week: Fees, Yield, and Soulbound
Learn how to build three different Token-2022 mints on Solana devnet in one week, including fee-bearing, interest-accruing, and soulbound tokens
Dev.to · atharv shukla
📰
Maximize Google Workspace AI Power: Safeguard Data and Boost Performance in 2026
Maximize Google Workspace AI power by safeguarding data and boosting performance to stay ahead in 2026
Dev.to AI
📰
What is Gemini Spark, and what can it actually do for you?
Gemini Spark integrates AI into daily Google apps to enhance productivity, learn how to leverage it
TechCabal
📰
How I use python to save hours every week
Learn how to use Python to automate tasks and save hours every week, with practical steps for beginners and experienced users alike.
Dev.to AI
Up next
Implement Microsoft Entra ID Auth with Delegated Graph API Calls in ASP.NET Core Web App Razor Pages
Dewiride Technologies
Watch →