<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Vue.js Developers - Medium]]></title>
        <description><![CDATA[Helping web professionals up their skill and knowledge of Vue.js - Medium]]></description>
        <link>https://medium.com/js-dojo?source=rss----ee1a14b301d---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Vue.js Developers - Medium</title>
            <link>https://medium.com/js-dojo?source=rss----ee1a14b301d---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Dec 2019 22:52:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/js-dojo" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Seven In One: “My Form” WebApp using VueJS+Vuetify+Firebase Hosting PART II]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/js-dojo/seven-in-one-my-form-webapp-using-vuejs-vuetify-firebase-hosting-part-ii-a76be7829714?source=rss----ee1a14b301d---4"><img src="https://cdn-images-1.medium.com/max/1280/1*XfbCgitZdeGD0ofJLaFV5g.jpeg" width="1280"></a></p><p class="medium-feed-snippet">In PART I, we made our environment and workspace ready for creating the Vue web app.</p><p class="medium-feed-link"><a href="https://medium.com/js-dojo/seven-in-one-my-form-webapp-using-vuejs-vuetify-firebase-hosting-part-ii-a76be7829714?source=rss----ee1a14b301d---4">Continue reading on Vue.js Developers »</a></p></div>]]></description>
            <link>https://medium.com/js-dojo/seven-in-one-my-form-webapp-using-vuejs-vuetify-firebase-hosting-part-ii-a76be7829714?source=rss----ee1a14b301d---4</link>
            <guid isPermaLink="false">https://medium.com/p/a76be7829714</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Nabil Mohammed]]></dc:creator>
            <pubDate>Thu, 19 Dec 2019 03:27:28 GMT</pubDate>
            <atom:updated>2019-12-19T03:27:28.452Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Seven In One: “My Form” WebApp using VueJS+Vuetify+Firebase Hosting]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/js-dojo/seven-in-one-my-form-webapp-using-vuejs-vuetify-firebase-hosting-1df64005bb8a?source=rss----ee1a14b301d---4"><img src="https://cdn-images-1.medium.com/max/1280/1*rODEkpJO6-klFgON_Gj2hA.jpeg" width="1280"></a></p><p class="medium-feed-snippet">This is PART I of a series of articles where we will be exploring several technologies combined in one project.</p><p class="medium-feed-link"><a href="https://medium.com/js-dojo/seven-in-one-my-form-webapp-using-vuejs-vuetify-firebase-hosting-1df64005bb8a?source=rss----ee1a14b301d---4">Continue reading on Vue.js Developers »</a></p></div>]]></description>
            <link>https://medium.com/js-dojo/seven-in-one-my-form-webapp-using-vuejs-vuetify-firebase-hosting-1df64005bb8a?source=rss----ee1a14b301d---4</link>
            <guid isPermaLink="false">https://medium.com/p/1df64005bb8a</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Nabil Mohammed]]></dc:creator>
            <pubDate>Mon, 16 Dec 2019 13:38:01 GMT</pubDate>
            <atom:updated>2019-12-16T13:38:01.188Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to solve vue.js prod build assets relative path problem]]></title>
            <link>https://medium.com/js-dojo/how-to-solve-vue-js-prod-build-assets-relative-path-problem-71f91138dd79?source=rss----ee1a14b301d---4</link>
            <guid isPermaLink="false">https://medium.com/p/71f91138dd79</guid>
            <category><![CDATA[vuejs-assets]]></category>
            <category><![CDATA[vuejs-assets-path-problem]]></category>
            <category><![CDATA[vuejs-publicpath]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vuejs-config-file]]></category>
            <dc:creator><![CDATA[Vipin Cheriyanveetil]]></dc:creator>
            <pubDate>Wed, 11 Dec 2019 09:24:50 GMT</pubDate>
            <atom:updated>2019-12-11T09:24:50.498Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jva6dJIylvHKYDqHs7Os7g.jpeg" /></figure><p>Hello,</p><p>After I got my i<a href="https://medium.com/tinywave/how-to-solve-the-vue-js-ui-error-during-new-installation-aba068b2522c">nstallation issues rectified</a> I created a new vuejs project using the vue UI which I fixed in one of my earlier posts. The vue UI was brilliant enough to get my first project created in no matter of time. I was excited about vue UI and its a very beautiful UI to manage your projects.</p><p>I was having <strong>vue/cli</strong> 3.5.3 and <strong>node.js</strong> v8.15</p><p>I installed the Visual Studio Code and opened the project and looked into the folders and files. I compiled the project using the vue UI and I opened the project in a browser and all looked good when I saw the default vue template on the screen with home and about pages. All worked good.</p><p>I then wanted to see if it gives me a good production build. So I did a build from the vue UI and build as successful. I saw the dist folder created with the required files in it. I copied the dist folder to one of my wamp apache server’s www folder. I browsed the project from the browser and I found oops, the site doesn’t show anything. I looked into the browser console and saw that none of the <strong>CSS </strong>and <strong>JS </strong>files loaded because of the reference problem.</p><p>below is my dist folder structure</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*1Kbwg4wuCQEEP0S3L2RNug.png" /></figure><p>I opened the index.html file it had a wrong path or it was not a relative path. Like below</p><pre>&lt;script src=/js/chunk-vendors.e4c467f6.js&gt;&lt;/script&gt;</pre><p>If you notice the src path starts with “/” and that was not right. It should start without “/” and should be like below</p><pre>&lt;script src=js/chunk-vendors.e4c467f6.js&gt;&lt;/script&gt;</pre><p>This is where vuejs is spoiling there impression. This was the code and output of their own sample project and it should have worked without any problem.</p><p>I then googled for hours and nobody has a clear solution. Most of them talked about settings this and that path and none of them worked. In one of the posts, it talked about setting something in the <strong>vue.config.js </strong>file. I searched for this file in the src folder and could not find it. As per vuejs documentation, this file is optional. I started hatting this framework.</p><p>I thought of adding this file manually and I added it and I inserted the below code in that file</p><pre>module.exports = {</pre><pre>publicPath: &#39;&#39;</pre><pre>};</pre><p>Like the below image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*2jdQQVTCgZwNNA2KNOHIZQ.png" /></figure><p>I compiled the code again and everything worked. I then did a prod build and it also was successful. I then moved the dist folder to my apache www path and I browsed the project with my fingers crossed and wow to my surprise it worked without any console errors and I could see the default page loaded and all links working.</p><p>Let this be helpful to everybody who is facing this issue.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71f91138dd79" width="1" height="1"><hr><p><a href="https://medium.com/js-dojo/how-to-solve-vue-js-prod-build-assets-relative-path-problem-71f91138dd79">How to solve vue.js prod build assets relative path problem</a> was originally published in <a href="https://medium.com/js-dojo">Vue.js Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to implement route guard in vue.js]]></title>
            <link>https://medium.com/js-dojo/how-to-implement-route-guard-in-vue-js-9929c93a13db?source=rss----ee1a14b301d---4</link>
            <guid isPermaLink="false">https://medium.com/p/9929c93a13db</guid>
            <category><![CDATA[route-guards]]></category>
            <category><![CDATA[route-authentication]]></category>
            <category><![CDATA[authenticate-your-router]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vuejs-route]]></category>
            <dc:creator><![CDATA[Vipin Cheriyanveetil]]></dc:creator>
            <pubDate>Mon, 09 Dec 2019 04:00:49 GMT</pubDate>
            <atom:updated>2019-12-09T04:00:49.485Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*NKePeWCDb5ge3fCG6goL0A.jpeg" /><figcaption>Implement Route Guard in vue.js</figcaption></figure><p>This becomes very crucial when you are developing an application that has registration and user login features. I was recently developing an application vue.js and I came to this situation to implement route authentication or guard.</p><p>Vue Router has few Navigation guards to help us here, that you can use as a hook before every route. Navigation Guard is written as a plain function that can be understood and used easily</p><p>Have a look at the below example.</p><h4>Write a common function to check if the user is authenticated.</h4><pre>function guardMyroute(to, from, next)<br>{<br> var isAuthenticated= false;<br> if(localStorage.getItem(&#39;LoggedUser))<br>  isAuthenticated = true;<br> else<br>  isAuthenticated= false;</pre><pre>if(isAuthenticated) {<br>  next(); // allow to enter route<br> } else{<br>  next(&#39;/login&#39;); // go to &#39;/login&#39;;<br> }<br>}</pre><p>The above function checks if a user is authenticated or not. The local storage item with key “LoggedUser” is set when a user uses the login form and logs in successfully to the system.</p><h4>Who sets the Localstorage item?</h4><p>This is very important. In most cases, it would be a <strong>Login component</strong> <strong>which calls a web API or by any other means</strong> to check if the provided credentials are valid and then sets this <strong>localstorage </strong>key as an indicator for whether the user is an authenticated one or not. In my example, the <strong>Login component</strong> sets the below after validating the credentials of a user.</p><p>Let us assume the <strong>userlogin </strong>validation API call returns the below response</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*JmLw0imdrBIXe_YlHYbVag.png" /></figure><p>So I would set the local storage to something like below</p><pre>localStorage.setItem(&#39;LoggedUser&#39;,results.User);</pre><h4>Lets now look at my router.</h4><pre>import Vue from &quot;vue&quot;;<br>import Router from &quot;vue-router&quot;;<br>import Login from &quot;./views/Login.vue&quot;;</pre><pre>Vue.use(Router);</pre><pre>export default new Router({<br>  routes: [<br>    {<br>      path: &quot;/&quot;,<br>      name: &quot;home&quot;,<br>      component: Login,<br>      meta: {title: &#39;Home&#39;}<br>    },<br>    {<br>      path: &quot;/login&quot;,<br>      name: &quot;login&quot;,<br>      component: Login,<br>      meta: {title: &#39;Login&#39;}<br>    },<br>    {<br>      path: &quot;/dashboard&quot;,<br>      name: &quot;dashboard&quot;,<br>      meta: {title: &#39;Dashboard&#39;},<br>      component: Dashboard,<br>    }<br>  ]<br>});</pre><p>It&#39;s quite simple . its now time to apply our function to the router guard.</p><h4>Let&#39;s hook the above function to the above router definition now. So the code would be like below</h4><pre>import Vue from &quot;vue&quot;;<br>import Router from &quot;vue-router&quot;;<br>import Login from &quot;./views/Login.vue&quot;;</pre><pre>Vue.use(Router);</pre><pre>function guardMyroute(to, from, next)<br>{<br> var isAuthenticated= false;<br>//this is just an example. You will have to find a better or <br>// centralised way to handle you localstorage data handling <br>if(localStorage.getItem(&#39;LoggedUser))<br>  isAuthenticated = true;<br> else<br>  isAuthenticated= false;</pre><pre> if(isAuthenticated) <br> {<br>  next(); // allow to enter route<br> } <br> else<br> {<br>  next(&#39;/login&#39;); // go to &#39;/login&#39;;<br> }<br>}</pre><pre>export default new Router({<br>  routes: [<br>    {<br>      path: &quot;/&quot;,<br>      name: &quot;home&quot;,<br>      beforeEnter : guardMyroute,<br>      component: Login,<br>      meta: {title: &#39;Home&#39;}<br>    },<br>    {<br>      path: &quot;/login&quot;,<br>      name: &quot;login&quot;,<br>      component: Login,<br>      meta: {title: &#39;Login&#39;}<br>    },<br>    {<br>      path: &quot;/dashboard&quot;,<br>      name: &quot;dashboard&quot;,<br>      beforeEnter : guardMyroute,<br>      meta: {title: &#39;Dashboard&#39;},<br>      component: Dashboard,<br>    }<br>  ]<br>});</pre><p>Have a look at the new router definitions and then you can see an additional guard being defined on each router. These guards are hooked to our function named “<strong>guardMyroute</strong>”. The guard name is “<strong>beforeEnter</strong>”.</p><p>So what happens is any time this route is triggered it automatically fires the route guard function and thus helps us to authenticate our routes.</p><p>Having said that there some guards that vuejs have in its pocket to help us with various needs. Below is some information on them</p><blockquote><strong><em>Route Guards are </em></strong><br><strong>beforeEnter</strong>: action before entering a specific route (unlike global guards, this has access to this) <strong>(</strong>this is what we have used in our above example<strong>)</strong></blockquote><blockquote><strong><em>The Global Guards are :</em></strong><br><strong>beforeEach</strong>: action before entering any route (cannot have access to <strong>this </strong>scope)<br><strong>beforeResolve</strong>: action before the navigation is confirmed, but after in-component guards (same as beforeEach with <strong>this </strong>scope access)<br><strong>afterEach</strong>: action after the route resolves (you cannot affect the navigation)</blockquote><blockquote><strong><em>The Component Guards would be :</em></strong><br><strong>beforeRouteEnter</strong>: action before navigation is confirmed, and before component creation (no access to <strong>this scope</strong>)<br><strong>beforeRouteUpdate</strong>: action after a new route has been called that uses the same component<br><strong>beforeRouteLeave</strong>: action before leaving a route</blockquote><p>hope it&#39;s simple. Enjoy programming</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9929c93a13db" width="1" height="1"><hr><p><a href="https://medium.com/js-dojo/how-to-implement-route-guard-in-vue-js-9929c93a13db">How to implement route guard in vue.js</a> was originally published in <a href="https://medium.com/js-dojo">Vue.js Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vue + Django — Best of Both Frontends, Part 2]]></title>
            <link>https://medium.com/js-dojo/django-vue-vuex-best-of-both-frontends-part-2-1dcb78215575?source=rss----ee1a14b301d---4</link>
            <guid isPermaLink="false">https://medium.com/p/1dcb78215575</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[vuex]]></category>
            <dc:creator><![CDATA[Mike Hoolehan]]></dc:creator>
            <pubDate>Mon, 09 Dec 2019 04:00:19 GMT</pubDate>
            <atom:updated>2019-12-09T04:00:19.214Z</atom:updated>
            <content:encoded><![CDATA[<h3>Vue + Django — Best of Both Frontends, Part 2</h3><p>In my <a href="https://medium.com/js-dojo/vue-django-best-of-both-frontends-701307871478">previous article</a> I demonstrated how to use Vue’s Multi-Page App (MPA) support to embed Vue Single File Components into a Django template, allowing developers to easily commingle usage of Django templates and Vue within an application.</p><p>The article implemented a very simple example. Since writing the article, I’ve received several questions regarding information sharing from Django to Vue and among Vue components on a single page.</p><p>In this article, I’ll explain how Vuex can be introduced into the Vue MPA and information can be</p><ul><li>shared between multiple components on a single page</li><li>persisted in components across page loads</li><li>passed from Django templates to Vue properties</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*9J48lxV2F724AITHxOmHhQ.png" /></figure><h3>Introducing Vuex to a Vue/Django Project</h3><p>I’ll introduce two simple Vue counter components to a single page of a Django application. These components will retrieve and mutate their state from the same Vuex store. Additionally, each counter will display a message provided as a Vue property from a Django template variable.</p><p>I’ll continue from where I left in Part 1: a working Django App integrated with a couple of Vue components. If you’re following along with the code, then the starting point in the example repo at is tagged <a href="https://github.com/ilikerobots/django-vue-mpa/tree/part_1">part_1</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pEP4H4_BuRHT-MLA.png" /><figcaption>Our starting point</figcaption></figure><h3>Adding Vuex</h3><p>We start by adding Vuex and the Vuex persistedstate plugin to our project. From the main project directory</p><pre>cd vue_frontend<br>yarn add vuex vuex-persistedstate</pre><h3>A Simple Counter Component</h3><p>Cribbing from Vuex’s tutorial, let’s create src/components/HelloWorld.vue with a simple counter component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afbdb858ce0617973cfa43d62ec2ef48/href">https://medium.com/media/afbdb858ce0617973cfa43d62ec2ef48/href</a></iframe><p>This component has a single property msg which will be shown above the counter readout. The computed count is retrieved from the Vuex store (which we haven&#39;t built yet) and displayed surrounded with buttons that, when clicked, call two methods ( increment and decrement) which in turn call state mutators.</p><p>Note that it might be more appropriate to utilize Vuex Actions here, but for simplicity I call the mutators directly.</p><h3>Multiple Components on a Page</h3><p>Now that we have a new component, we need to include it in our Django template. Just as in Part 1, we’ll create a new entry point and instruct Vue how to mount our DOM elements. The only conceptual difference is that this time we mount multiple components. However, due to a great deal of nuance in how Vue is loaded in a MVA, there are some specific ways we must code our entry point to ensure that properties may be read and that state can be shared across components.</p><p>Create a new file index.js with the contents:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1f62899ccd2b453caba3da29a33794f/href">https://medium.com/media/b1f62899ccd2b453caba3da29a33794f/href</a></iframe><p>Again, with the exception of importing and using Vuex, this conceptually parallels our other entry points. But there are differences in how we import Vue and and in how we mount the components. First, we import Vue from vue/dist/vue.js which will be necessary later when we want to make our Vuex store shared across components. Second, mounting components using the el/ components method instead of render/$mount allows us to capture properties provided directly from static HTML.</p><p>Note we’re mounting the same component twice, but we could have mounted a second component instead if we had one available.</p><p>With our endpoint designed, we next tell Vue about it. Modify vue.config.js and update the pages configuration to include our new endpoint:</p><pre><strong>const</strong> pages = {<br>    &quot;index&quot;: {<br>        entry: &quot;./src/index.js&quot;,<br>        chunks: [&quot;chunk-vendors&quot;],<br>    },<br>    ...<br>};</pre><p>And finally, we update our Django template index.html to include the #hello_world_a and #hello_world_b DOM elements that we specified in our entry point:</p><pre>{% <strong>with</strong> msg0=&quot;The Left Counter&quot; msg1=&quot;The Right Counter&quot; %}<br>  <strong>&lt;div</strong> id=&quot;hello_world_a&quot; style=&quot;width: 49%; display: inline-block&quot;<strong>&gt;</strong><br>    <strong>&lt;hello-world</strong> msg=&quot;{{ <em>msg0</em> }}&quot;<strong>&gt;&lt;/hello-world&gt;</strong><br>  &lt;<strong>/div&gt;</strong><br>  <strong>&lt;div</strong> id=&quot;hello_world_b&quot; style=&quot;width: 49%; display: inline-block&quot;<strong>&gt;</strong><br>    <strong>&lt;hello-world</strong> msg=&quot;{{ <em>msg1</em> }}&quot;<strong>&gt;&lt;/hello-world&gt;</strong><br>  <strong>&lt;/div&gt;</strong><br>{% <strong>endwith</strong> %}<br><br>{% <strong>render_bundle</strong> &#39;chunk-vendors&#39; %}<br>{% <strong>render_bundle</strong> &#39;index&#39; %}</pre><p>Both elements are included on the page, and we pass each a msg property that is taken from a Django template variable. The variables are static strings here, but they could easily be context variables or the output of a template tag.</p><p>If we tried to run our application now, we’d receive some errors about state not being defined, because we haven&#39;t yet built our store.</p><h3>Building a Vuex Store</h3><p>Our HelloWorld component depends on a Vuex store, so let’s add that.</p><p>Create a new folder vuex inside src. I find it useful to organize my store into modules, so start by creating a file src/vuex/vuex_module_counter.js with the state and mutators our HelloWorld component needs:</p><pre><em>export</em> default {<br>    state: {<br>        count: 0<br>    },<br>    mutations: {<br>        increment: state =&gt; state.count++,<br>        decrement: state =&gt; state.count--<br>    },<br>}</pre><p>Next we need to instantiate a Vuex store. While this is normally quite straightforward, because we want to share state across components on the same page, we need to work around that fact that Vue will create separate store instances for each component in our MVA. Luckily, I noted that GitHub user <a href="https://github.com/sumobrian">sumobrian</a> forked my repo and included a very clever way to accomplish this using a technique described first (I believe) in <a href="https://blog.toast38coza.me/make-your-vuex-store-globally-available-by-registering-it-as-a-plugin/">this blog post</a> by <a href="https://blog.toast38coza.me/author/christo-crampton/">Christo Crampton</a>.</p><p>Create a new file vuex/vuex_store_as_plugin.js with the contents:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe5a2e87b1a7fc72fb7894bc1fef63e5/href">https://medium.com/media/fe5a2e87b1a7fc72fb7894bc1fef63e5/href</a></iframe><p>The setup of the store is very similar to those described in Vuex tutorials. However, I’ll note a few differences.</p><p>First, we are utilizing the createPersistedState plugin, letting that plugin know that we’d like the count state to be preserved throughout a visitor&#39;s session. The plugin will take care of all the details for us. Note if we had a more complex application with many state variables, we can here choose which of those we&#39;d like persisted.</p><p>Next, we create a Vuex store, utilizing the counter module we created earlier. We could easily include any number of additional modules here.</p><p>Lastly, per Christo’s technique, we export a Vue plugin that does a single thing, which is to override the standard $store object with our common store. This will ensure that all our components on a single page will be utilizing the same store instance.</p><p>Now that we’ve built our Vuex-Store-As-Plugin, let’s instruct our entrypoint index.js to use it by adding a couple lines:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d26d1f15294fa3888efcc329b7c5745/href">https://medium.com/media/9d26d1f15294fa3888efcc329b7c5745/href</a></iframe><p>Note we do not include any reference to the store in the Vue constructors, because we are instead using our store via a plugin.</p><p>That’s it! It’s time to…</p><h3>Admire Our Work</h3><p>Run your Django dev server,</p><pre>./manage.py runserver</pre><p>fire up the Vue frontend,</p><pre>cd vue_frontend<br>yarn serve</pre><p>and point your browser to the URL reported to you (probably <a href="http://localhost:8080).">http://localhost:8080).</a></p><p>You will see your two counters peacefully coexisting on a single page, harmoniously sharing state, uniquely described by a variable property.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RzNwpFHS45XZk2sp.png" /></figure><p>Increment the counters a few times and reload the page, and the persistedstate plugin will ensure the last state is restored.</p><h3>Conclusion</h3><p>By introducing multiple Vue components managed by a common Vuex state to a single Django page, it is easy to intermingle the two frontend technologies, leveraging each wherever it would be most suitable without sacrificing the strengths of either.</p><h3>Acknowledgements</h3><p>As noted above, I was first made aware of the Vuex-Store-As-Plugin technique by GitHub user <a href="https://github.com/sumobrian">sumobrian</a> in his <a href="https://github.com/sumobrian/django-vue-mpa/commits/master">fork of my repo</a>. The technique he implemented was first described (I believe) by <a href="https://blog.toast38coza.me/author/christo-crampton/">Christo Crampton</a> in his blog article <a href="https://blog.toast38coza.me/make-your-vuex-store-globally-available-by-registering-it-as-a-plugin/"><em>Make your vuex store globally available by registering it as a plugin</em></a>. Thanks to both!</p><h3>Source</h3><p>See <a href="https://github.com/ilikerobots/django-vue-mpa">django-vue-mpa</a> on github.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1dcb78215575" width="1" height="1"><hr><p><a href="https://medium.com/js-dojo/django-vue-vuex-best-of-both-frontends-part-2-1dcb78215575">Vue + Django — Best of Both Frontends, Part 2</a> was originally published in <a href="https://medium.com/js-dojo">Vue.js Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to set timer idle in Vue]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/js-dojo/how-to-set-timer-idle-in-vue-1f4b57beb886?source=rss----ee1a14b301d---4"><img src="https://cdn-images-1.medium.com/max/2114/1*jH50i7SSxzT3BG_NLXj5Uw.png" width="2114"></a></p><p class="medium-feed-snippet">Do you need to check for the inactivity of the user in your Vue apps? If the user is inactive in a period of time, then you wanna&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/js-dojo/how-to-set-timer-idle-in-vue-1f4b57beb886?source=rss----ee1a14b301d---4">Continue reading on Vue.js Developers »</a></p></div>]]></description>
            <link>https://medium.com/js-dojo/how-to-set-timer-idle-in-vue-1f4b57beb886?source=rss----ee1a14b301d---4</link>
            <guid isPermaLink="false">https://medium.com/p/1f4b57beb886</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vuex]]></category>
            <category><![CDATA[idle]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[vue]]></category>
            <dc:creator><![CDATA[Jakz Aizzat]]></dc:creator>
            <pubDate>Mon, 09 Dec 2019 03:58:15 GMT</pubDate>
            <atom:updated>2019-12-09T03:58:14.978Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Chrome Extensions For Front-End Developer to Increase Productivity]]></title>
            <link>https://medium.com/js-dojo/chrome-extensions-for-front-end-developer-to-increase-productivity-98f3e48dc14c?source=rss----ee1a14b301d---4</link>
            <guid isPermaLink="false">https://medium.com/p/98f3e48dc14c</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <dc:creator><![CDATA[Oahehc (Andrew)]]></dc:creator>
            <pubDate>Mon, 02 Dec 2019 04:55:54 GMT</pubDate>
            <atom:updated>2019-12-02T04:55:54.468Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Lgji4Inkh1LaCLCtNHdJw.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/@caio?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Caio Resende </a>from <a href="https://www.pexels.com/photo/light-smartphone-macbook-mockup-67112/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pexels</a></figcaption></figure><blockquote>Nowadays, the front-end field becomes more and more complex. So our time is limit and should be used wisely. Therefore, I keep looking for tools or tips to increase my productivity. I had shared an article about <a href="https://medium.com/js-dojo/40-keyboard-shortcuts-help-speed-up-front-end-developers-workflow-fb9b51736300">how I use keyboard shortcuts into my developing process</a>. In the article, I want to share some useful Chrome extensions for front-end developers.</blockquote><p><strong>TL;DR, those are the extensions I’m going to introduce in article.</strong></p><ol><li><a href="https://chrome.google.com/webstore/detail/utime/kpcibgnngaaabebmcabmkocdokepdaki">Utime</a></li><li><a href="https://chrome.google.com/webstore/detail/change-timezone-time-shif/nbofeaabhknfdcpoddmfckpokmncimpj">Change Timezone</a></li><li><a href="https://chrome.google.com/webstore/detail/figure-it-out/lialghmkggocekkpjbnoacohodmckfke">Figure it Out</a></li><li><a href="https://chrome.google.com/webstore/detail/colorzilla/bhlhnicpbhignbdhedgjhgdocnmhomnp">ColorZilla</a></li><li><a href="https://chrome.google.com/webstore/detail/page-ruler/emliamioobfffbgcfdchabfibonehkme">Page Ruler</a></li><li><a href="https://chrome.google.com/webstore/detail/whatfont/jabopobgcpjmedljpbcaablpmlmfcogm">WhatFont</a></li><li><a href="https://chrome.google.com/webstore/detail/wappalyzer/gppongmhjkpfnbhagpmjfkannfbllamg">Wappalyzer</a></li><li><a href="https://chrome.google.com/webstore/detail/incognito-this/aglfgiceepbeffbpmlohbdnhmliojinm">Incognito This</a></li><li><a href="https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc">JSONView</a></li><li><a href="https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg">User-Agent Switcher for Chrome</a></li><li><a href="https://chrome.google.com/webstore/detail/pushbullet/chlffgpmiacpedhhbkiomidkjlcfhogd">Pushbullet</a></li><li><a href="https://chrome.google.com/webstore/detail/awesome-autocomplete-for/djkfdjpoelphhdclfjhnffmnlnoknfnd">Awesome Autocomplete for GitHub</a></li><li><a href="https://chrome.google.com/webstore/detail/refined-github/hlepfoohegkhhmjieoechaddaejaokhf">Refined GitHub</a></li><li><a href="https://chrome.google.com/webstore/detail/the-great-suspender/klbibkeccnjlkjkiokjodocebajanakg">The Great Suspender</a></li><li><a href="https://chrome.google.com/webstore/detail/google-publisher-toolbar/omioeahgfecgfpfldejlnideemfidnkc">Google Publisher Toolbar</a></li><li><a href="https://chrome.google.com/webstore/detail/tag-assistant-by-google/kejbdjndbnbjgmefkgdddjlbokphdefk">Tag Assistant</a></li><li><a href="https://chrome.google.com/webstore/detail/facebook-pixel-helper/fdgfkebogiimcoedlicjlajpkdmockpc">FB pixel helper</a></li><li><a href="https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi">React Developer Tools</a></li><li><a href="https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd">Redux DevTools</a></li><li><a href="https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd">Vue.js devtools</a></li></ol><p>—</p><p>In this article, I will categories those extensions into a few different groups base on the purpose I used them.</p><h3>I. Timezone &amp; Timestamp</h3><ul><li><a href="https://chrome.google.com/webstore/detail/utime/kpcibgnngaaabebmcabmkocdokepdaki">Utime</a>: Transfer timestamp into a human-readable date string.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*-07oF61l4_ZOoVmT5-0Hmw.png" /></figure><ul><li><a href="https://chrome.google.com/webstore/detail/change-timezone-time-shif/nbofeaabhknfdcpoddmfckpokmncimpj">Change Timezone</a>: switch your browser timezone<br>If you want to display time in a different timezone. Change Timezone can help you to make sure your application works correctly in a different timezone.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KijWVVmDDmrz_k_EmThgtg.png" /></figure><ul><li><a href="https://chrome.google.com/webstore/detail/figure-it-out/lialghmkggocekkpjbnoacohodmckfke">Figure it Out</a>: display current time for different timezone <br>If your team works in a different timezone or you have to constantly travel to a different country. Figure it Out can help you figure out the current time in your target city. This is helpful when you what to contact a person in a different timezone.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oINDkuiiuj0oq1XXLb8pRw.png" /></figure><h3>II. Design</h3><ul><li><a href="https://chrome.google.com/webstore/detail/colorzilla/bhlhnicpbhignbdhedgjhgdocnmhomnp">ColorZilla</a>: To get the color code from a website element.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xF7lgVpif2qnnipLpZ4mDg.png" /></figure><ul><li><a href="https://chrome.google.com/webstore/detail/page-ruler/emliamioobfffbgcfdchabfibonehkme">Page Ruler</a>: To check a website element’s position and size.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nkVO0_d2HVUt0Oa3TKWnHw.png" /></figure><ul><li><a href="https://chrome.google.com/webstore/detail/whatfont/jabopobgcpjmedljpbcaablpmlmfcogm">WhatFont</a>: To get the website’s font-family setting.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TGDRGoqt-GJMMYaIB97-yQ.png" /></figure><h3>III. Developer</h3><ul><li><a href="https://chrome.google.com/webstore/detail/wappalyzer/gppongmhjkpfnbhagpmjfkannfbllamg">Wappalyzer</a>: To get the technologies used on the target website.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*JinVLsLCtUYjWJo8GlzFPw.png" /></figure><ul><li><a href="https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc">JSONView</a>: To format the JSON which response by an API.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JwRUaCH2EPk6L33ZHwB4pA.png" /></figure><ul><li><a href="https://chrome.google.com/webstore/detail/incognito-this/aglfgiceepbeffbpmlohbdnhmliojinm">Incognito This</a>: Turn your current active tab into incognito<br>Sometimes, use the incognito tab can help us prevent lots of problems and make sure our application work as expected when it have no cache.</li></ul><h3>IV. Cross Browser &amp; Device</h3><ul><li><a href="https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg">User-Agent Switcher for Chrome</a>: Switch your user-agent into different browsers or devices. <br>If you use user-agent to detect the browser and make different effects. This can help you to have a quick validate the result.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*9ww26gdwe43IprLmlHgzRA.png" /></figure><ul><li><a href="https://chrome.google.com/webstore/detail/pushbullet/chlffgpmiacpedhhbkiomidkjlcfhogd">Pushbullet</a>: Send a link or some message to different devices<br>Sometimes, we have to test our application on different devices. This can help us pass the link to the target device.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OsHxHxVpR2oNjmGRxBhf-Q.png" /></figure><h3>V. GitHub</h3><ul><li><a href="https://chrome.google.com/webstore/detail/awesome-autocomplete-for/djkfdjpoelphhdclfjhnffmnlnoknfnd">Awesome Autocomplete for GitHub</a>: autocomplete the GitHub search bar.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*IZVYEgTt_cEQcjTSJ4OOhA.png" /></figure><ul><li><a href="https://chrome.google.com/webstore/detail/refined-github/hlepfoohegkhhmjieoechaddaejaokhf">Refined GitHub</a>: adds some useful features on the GitHub web application.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_iO55eUABUpOZ-21l_vO_A.png" /></figure><h3>VI. Performance</h3><ul><li><a href="https://chrome.google.com/webstore/detail/the-great-suspender/klbibkeccnjlkjkiokjodocebajanakg">The Great Suspender</a><br>Suspend the tabs in the background if it hasn’t be used for a specific time. This can help us free up the memory and CPU.</li></ul><h3><strong>VII. Service &amp; Framework</strong></h3><p>Other extensions for specific service or framework</p><ul><li><a href="https://chrome.google.com/webstore/detail/google-publisher-toolbar/omioeahgfecgfpfldejlnideemfidnkc">Google Publisher Toolbar</a>: for Google AdSense, Ad Exchange, DFP</li><li><a href="https://chrome.google.com/webstore/detail/tag-assistant-by-google/kejbdjndbnbjgmefkgdddjlbokphdefk">Tag Assistant</a>: for Google Analytics, Google Tag Manager</li><li><a href="https://chrome.google.com/webstore/detail/facebook-pixel-helper/fdgfkebogiimcoedlicjlajpkdmockpc">FB pixel helper</a></li><li><a href="https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi">React Developer Tools</a></li><li><a href="https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd">Redux DevTools</a></li><li><a href="https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd">Vue.js DevTools</a></li></ul><p>—</p><p>Thanks for you’re reading. I hope the information can help you boost up your developing process.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98f3e48dc14c" width="1" height="1"><hr><p><a href="https://medium.com/js-dojo/chrome-extensions-for-front-end-developer-to-increase-productivity-98f3e48dc14c">Chrome Extensions For Front-End Developer to Increase Productivity</a> was originally published in <a href="https://medium.com/js-dojo">Vue.js Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[English] Template — Vue JS + Asp.Net Core — Visual Studio 2019]]></title>
            <link>https://medium.com/js-dojo/english-template-vue-js-asp-net-core-visual-studio-2019-40bf77f735aa?source=rss----ee1a14b301d---4</link>
            <guid isPermaLink="false">https://medium.com/p/40bf77f735aa</guid>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <dc:creator><![CDATA[Alexandre Malavasi]]></dc:creator>
            <pubDate>Thu, 28 Nov 2019 12:05:09 GMT</pubDate>
            <atom:updated>2019-11-28T12:05:08.943Z</atom:updated>
            <content:encoded><![CDATA[<h3>[English] Template — Vue JS + Asp.Net Core — Visual Studio 2019</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VfzWWFMJAvEH8B3g.png" /></figure><p>All my friends and people close to me know that I’m fun of Vue JS and .NET Core, at the same time. Among many existent options for developing Single Page Application (SPA), I have special consideration of Vue JS, even I like so much Angular as well.</p><p>By default, the Visual Studio does not have any template specifically for Vue JS + Asp.Net Core, like it has for Angular + Asp.Net Core. Setup from scratch a Vue JS application with all necessary configurations sometimes could take a lot of time: webpack, loads of packages, Middleware configuration for SPA in Asp.Net Core startup.</p><p>Because of that, I created to help the technical community my own template of Vue JS application together with Asp.Net Core Web API application in the backend side. The template is available at the following link:</p><p><a href="https://marketplace.visualstudio.com/items?itemName=alexandredotnet.vuejsdotnetcore&amp;ssr=false#overview">VueJS with .NET Core 2.2 Template</a></p><h3>Installation</h3><p>To use it just download the extension at the given link and follow the step by step after execute file. Details in the following images:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/0*4B13ZlJkncIz-_qu.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/0*VCmjioPWPstcr7iq.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/0*0aM7p2mVApBo8a16.jpeg" /></figure><h3>Usage</h3><p>To use it after the installation , just o Visual Studio 2019, escolher a opção para criar um novo projeto e realizar a busca do template. Ele já estará na lista disponível:</p><p>To use it after the installation, just open the Visual Studio 2019, choose the option to create a new project e search the template by name. It’ll be already installed and available on the template list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rKMCdras0uQ2YErL.jpeg" /></figure><p>Feito isso, é só confirmação a criação do projeto. Esta é a estrutura básica padrão:</p><p>After that, just confirm the project creation. It is how the structure looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*ffnojLmllif4xY0Q.jpeg" /></figure><p>The project has a standard configuration of Asp.Net Core Web Api (2.2 version) and also a Vue JS project setup on the ClientApp folder, with all the basic and needed configurations.</p><p>All the extra needed settings on Asp.Net Core Startup file were already made as well, including the mandatory packages for Vue JS SPA Middleware:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*saKhgbsWfaDo-EIy.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/0*eIzywSoe85nqA6gL.jpeg" /></figure><h3>Run the project</h3><p>After creating the project, the only thing that you need to do is running it.</p><p>PS: in case of the Visual Studio opens a URL different from the root (e.g localhost/api/values), just type the root of the application (the main domain without any folder path) to execute the Vue JS application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OwkqFN_kEwE6WDLh.png" /></figure><h3>Conclusion</h3><p>I hope that helps you in your daily routine as a software developer, being important stuff to save your time every time you have to create Vue JS + Asp.Net Core application.</p><p>In case of any questions, feel free to ask me right here.</p><p>Thank you for reading this article till the end. Following are my social media profiles where I frequently share my technical posts and information on IT Events.</p><p>Also, I’ve shared the links to Caqui Coders, the Brazilian technical community that I’m one of the organizers.</p><p><strong>Twitter</strong>: <a href="https://twitter.com/alemalavasi">https://twitter.com/alemalavasi</a><br><strong>Linkedin</strong>: <a href="https://www.linkedin.com/in/alexandremalavasi/">https://www.linkedin.com/in/alexandremalavasi/</a></p><p>T</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/0*ciaTd6zOCIijtIqS.png" /></figure><ul><li>Facebook: <a href="https://www.facebook.com/caquicoders/">https://www.facebook.com/caquicoders/</a></li><li>Meetup : <a href="https://www.meetup.com/pt-BR/CaquiCoders/">https://www.meetup.com/pt-BR/CaquiCoders/</a></li><li>Canal no Youtube: <a href="https://www.youtube.com/CaquiCoders">https://www.youtube.com/CaquiCoder</a>s</li><li>Instagram: <a href="https://www.instagram.com/caquicoders/">https://www.instagram.com/caquicoders/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40bf77f735aa" width="1" height="1"><hr><p><a href="https://medium.com/js-dojo/english-template-vue-js-asp-net-core-visual-studio-2019-40bf77f735aa">[English] Template — Vue JS + Asp.Net Core — Visual Studio 2019</a> was originally published in <a href="https://medium.com/js-dojo">Vue.js Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When to “Unstub” a Component in a Vue.js Unit Test]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/js-dojo/when-to-unstub-a-component-in-a-vue-js-unit-test-608c7d1c646?source=rss----ee1a14b301d---4"><img src="https://cdn-images-1.medium.com/max/1200/1*fjkSvhcbS60iiUgP5KZyVQ.jpeg" width="1200"></a></p><p class="medium-feed-snippet">To test a component in isolation you can replace it&#x2019;s children components by stubbing them. Vue Test Utils can automatically do this for&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/js-dojo/when-to-unstub-a-component-in-a-vue-js-unit-test-608c7d1c646?source=rss----ee1a14b301d---4">Continue reading on Vue.js Developers »</a></p></div>]]></description>
            <link>https://medium.com/js-dojo/when-to-unstub-a-component-in-a-vue-js-unit-test-608c7d1c646?source=rss----ee1a14b301d---4</link>
            <guid isPermaLink="false">https://medium.com/p/608c7d1c646</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Anthony Gore]]></dc:creator>
            <pubDate>Wed, 27 Nov 2019 06:05:24 GMT</pubDate>
            <atom:updated>2019-12-19T14:07:56.338Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to Serve Vue with Nest]]></title>
            <link>https://medium.com/js-dojo/how-to-serve-vue-with-nest-f23f10b33e1?source=rss----ee1a14b301d---4</link>
            <guid isPermaLink="false">https://medium.com/p/f23f10b33e1</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Zak Miller]]></dc:creator>
            <pubDate>Mon, 18 Nov 2019 04:12:54 GMT</pubDate>
            <atom:updated>2019-11-18T04:12:54.372Z</atom:updated>
            <content:encoded><![CDATA[<p>Want to serve a VueJS app from a NestJS backend? Here’s how you do it.</p><h3>Create a new Nest app</h3><p>Install the Nest CLI</p><pre>npm install -g @nestjs/cli</pre><p>Create the NestJS app</p><pre>nest new nest-with-vue</pre><p>Install the dependencies</p><pre>cd nest-with-vue npm install</pre><h3>Verify it’s all working properly</h3><p>First, run it (this will watch the folder so we won’t have to restart the server as we make changes):</p><pre>npm run start:dev</pre><p>Then, hit it (in a separate terminal window):</p><pre>curl localhost:3000</pre><p>You should get Hello World!.</p><h3>Set it up to serve static content</h3><p>Install the package:</p><pre>npm install --save @nestjs/serve-static</pre><h3>Use the package</h3><p>src/app.module.ts:</p><pre>import { Module } from &#39;@nestjs/common&#39;;<br>import { AppController } from &#39;./app.controller&#39;;<br>import { AppService } from &#39;./app.service&#39;;<br>import { ServeStaticModule} from &#39;@nestjs/serve-static&#39;; // New<br>import { join } from &#39;path&#39;; // New<br><br>@Module({<br>  imports: [<br>    ServeStaticModule.forRoot({ // New<br>      rootPath: join(__dirname, &#39;..&#39;, &#39;client/dist&#39;), // New<br>    }), // New<br>  ],<br> controllers: [AppController],<br> providers: [AppService],<br>})<br>export class AppModule {}</pre><p>src/main.ts:</p><pre>import { NestFactory } from &#39;@nestjs/core&#39;;<br>import { AppModule } from &#39;./app.module&#39;;<br><br>async function bootstrap() {<br>  const app = await NestFactory.create(AppModule);<br>  app.setGlobalPrefix(&#39;api&#39;); // New<br>  await app.listen(3000);<br>}<br>bootstrap();</pre><p>We’re moving all the existing endpoints to under /api, and then serving the static content in the ./client/dist folder (which doesn&#39;t exist yet) when someone hits the root (in this case localhost:3000).</p><p>Also note that the name client here could be anything. It&#39;s just the folder where we&#39;re going to put the Vue app.</p><h3>Verify that the controller endpoint moved</h3><p>Now, if we hit the previous endpoint:</p><pre>curl localhost:3000</pre><p>You should get {&quot;statusCode&quot;:500,&quot;message&quot;:&quot;Internal server error&quot;}.</p><p>But if you hit the new /api endpoint:</p><pre>curl localhost:3000/api</pre><p>You get Hello World! again.</p><p>Now we just have to create the Vue app in that ./client/dist folder.</p><h3>Create the VueJS app</h3><p>Install the Vue CLI:</p><pre>npm install -g @vue/cli<br># OR <br>yarn global add @vue/cli</pre><p>Create the app:</p><pre>vue create client</pre><p>Build the app:</p><pre>cd client<br>npm run build</pre><p>This will put all the static files in ./client/dist, right where the Nest app will be looking for them.</p><h3>Verify that Nest is serving the compiled Vue app</h3><pre>curl localhost:3000</pre><p>You should get something that looks like:</p><pre>&lt;!DOCTYPE html&gt;&lt;html lang=en&gt; ... &lt;strong&gt;We&#39;re sorry but client doesn&#39;t work properly without JavaScript enabled. Please enable it to continue.&lt;/strong&gt; ... &lt;/html&gt;</pre><p>Which is the HTML being served by the Vue app.</p><p>Open it up in your browser and you’ll see it’s working!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GypJAa4VY9aI4-N9.png" /></figure><h3>Closing words</h3><p>That’s it. You can find the complete code <a href="https://github.com/ZakMiller/NestWithVue">here</a>.</p><p><em>Originally published at </em><a href="https://www.zakmiller.com/posts/serve-vue-with-nest/"><em>https://www.zakmiller.com</em></a><em> on November 11, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f23f10b33e1" width="1" height="1"><hr><p><a href="https://medium.com/js-dojo/how-to-serve-vue-with-nest-f23f10b33e1">How to Serve Vue with Nest</a> was originally published in <a href="https://medium.com/js-dojo">Vue.js Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>