<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jesús R. Méndez</title>
    <description>The latest articles on DEV Community by Jesús R. Méndez (@jesusrmendez).</description>
    <link>https://dev.to/jesusrmendez</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F364948%2F151b18d3-3e3f-477a-8975-3c9fa7b4a75a.jpeg</url>
      <title>DEV Community: Jesús R. Méndez</title>
      <link>https://dev.to/jesusrmendez</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jesusrmendez"/>
    <language>en</language>
    <item>
      <title>How to deploy Vue.js + Firebase</title>
      <dc:creator>Jesús R. Méndez</dc:creator>
      <pubDate>Wed, 19 Aug 2020 02:02:24 +0000</pubDate>
      <link>https://dev.to/jesusrmendez/how-to-deploy-vue-js-firebase-1iic</link>
      <guid>https://dev.to/jesusrmendez/how-to-deploy-vue-js-firebase-1iic</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZLdNnwzG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3maa62nhv0t1nk00yokw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZLdNnwzG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3maa62nhv0t1nk00yokw.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  Photo by Prateek Katyal from Pexels
&lt;/h6&gt;

&lt;p&gt;I always &lt;em&gt;forget&lt;/em&gt; how to deploy SPA applications like &lt;strong&gt;Vue or React&lt;/strong&gt; in firebase hosting the process is easy so I decided finally to make a tutorial for whom that will need it and for me.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is gonna be cover in this tutorial?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setup the firebase Hosting Project&lt;/li&gt;
&lt;li&gt;Installing the Firebase CLI&lt;/li&gt;
&lt;li&gt;Configuring your local project with environment variables&lt;/li&gt;
&lt;li&gt;Initialize Firebase Project using Firebase CLI Tools&lt;/li&gt;
&lt;li&gt;Deploy your application&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Setup the firebase Hosting Project
&lt;/h1&gt;

&lt;p&gt;We have two ways to make the setup. It can be using the &lt;strong&gt;web site or the firebase-cli&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 - Register&lt;/strong&gt;&lt;br&gt;
First, we need to register our project in &lt;a href="https://console.firebase.google.com/"&gt;firebase&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RBIgxtgs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/firebase-create-project.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RBIgxtgs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/firebase-create-project.png" alt="Register"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 - Install Firebase CLI&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g firebase-tool
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3 - Log in with Firebase client&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;firebase login
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So the browser will open to enable you to select your Google account. Once you complete the authentication process the following webpage will be displayed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AEVZ6sBt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/firebase-cli-sucess.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AEVZ6sBt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/firebase-cli-sucess.png" alt="IMAGE"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Configuring your local project with environment variables
&lt;/h1&gt;

&lt;p&gt;First, if you already have your project you only need to add the files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;.env.development&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.env.production&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;the content the file is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VUE_APP_FIREBASE_API_KEY=''
VUE_APP_FIREBASE_DOMAIN=''
VUE_APP_FIREBASE_DB_URL=''
VUE_APP_FIREBASE_PROJECT_ID=''
VUE_APP_FIREBASE_STORAGE_BUCKET=''
VUE_APP_FIREBASE_MESSAGING_SENDER_ID=''
VUE_APP_FIREBASE_API_ID=''
VUE_APP_FIREBASE_MEASUREMENT_ID=''
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Of course, every file you can fill with correct value depends on the environment.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that all variables that start with &lt;code&gt;VUE_APP_&lt;/code&gt; will be statically embedded into the client bundle with &lt;code&gt;webpack.DefinePlugin&lt;/code&gt; &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Initialize Firebase Project using Firebase CLI Tools
&lt;/h1&gt;

&lt;p&gt;We now initialize the firebase project with Firebase-CLI tools in our local project app directory executing the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;firebase init
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Step 1&lt;/strong&gt;
We choose &lt;em&gt;Hosting&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WwivJGmw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/firebase-cli-init.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WwivJGmw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/firebase-cli-init.png" alt="IMAGE"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Step 2&lt;/strong&gt;
The next step we asked if we won't use the existing project or make a new project from the console, for this tutorial we choose:  &lt;strong&gt;use and existing project.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0-FxtNWJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/firebase-association-project.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0-FxtNWJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/firebase-association-project.png" alt="Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Step 3&lt;/strong&gt;
The next step is where the application deploys the site, the default settings for vuejs the deploy folder is &lt;code&gt;dist&lt;/code&gt; when firebase-cli ask about &lt;code&gt;public directory&lt;/code&gt; we answer writing &lt;code&gt;dist&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wiRpgcP2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/firebase-setting.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wiRpgcP2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/firebase-setting.png" alt="IMAGE"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: If later we want to change where is output our &lt;code&gt;dist&lt;/code&gt; we only updated the file &lt;code&gt;firebase.json&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1&gt;
  
  
  Deploy your application
&lt;/h1&gt;

&lt;p&gt;So, finally the deploy we only need to execute two commands to build our Vue project and deploy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build &amp;amp;&amp;amp; firebase deploy
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And we expect the next output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_j2V5Mn---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/output-vue-build.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_j2V5Mn---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/output-vue-build.png" alt="IMAGE"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qkuFZejZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/output-vue-deploy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qkuFZejZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/output-vue-deploy.png" alt="IMAGE"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9ONCyf-p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/firebase-deploy-webpage.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9ONCyf-p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/JesusRMendez/DevTo/master/firebase-deploy-webpage.png" alt="IMAGE"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>firebase</category>
      <category>vue</category>
      <category>npm</category>
    </item>
  </channel>
</rss>
