{"id":270,"date":"2019-09-02T07:30:26","date_gmt":"2019-09-02T07:30:26","guid":{"rendered":"https:\/\/docs.theironnetwork.org\/vuely\/?page_id=270"},"modified":"2019-10-19T07:20:50","modified_gmt":"2019-10-19T07:20:50","slug":"deployment","status":"publish","type":"page","link":"https:\/\/docs.theironnetwork.org\/vuely\/deployment\/","title":{"rendered":"Deployment"},"content":{"rendered":"\n<p>To create a production build you need to run the command <code>npm run build<\/code>. It will create the <code>dist<\/code> folder, that contains the production build files. Now you just need to upload the <code>dist<\/code> files on to the server.<\/p>\n\n\n\n<h6>Static Server:<\/h6>\n\n\n\n<p>To run the production build locally, the easiest way to handle this would be to install <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/zeit\/serve\" target=\"_blank\">serve<\/a> and let it handle the rest: <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">npm install -g serve<br>serve -s dist<\/pre>\n\n\n\n<p>You don\u2019t necessarily need a static server in order to run a project in production. It works just as fine as integrated into an existing dynamic one.<\/p>\n\n\n\n<p>Here\u2019s a programmatic example using <a rel=\"noreferrer noopener\" href=\"https:\/\/nodejs.org\/\" target=\"_blank\">Node<\/a> and <a rel=\"noreferrer noopener\" href=\"http:\/\/expressjs.com\/\" target=\"_blank\">Express<\/a>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">const express = require('express');<br>const path = require('path');<br>const app = express();<br> <br>\u200bapp.use(express.static(path.join(__dirname, 'dist')));<br> <br>\u200bapp.get('\/', function (req, res) {  <br>    res.sendFile(path.join(__dirname, 'dist', 'index.html'));<br>});<br> <br>\u200bapp.listen(9000);<\/pre>\n\n\n\n<h6>Apache HTTP server:<\/h6>\n\n\n\n<p>If you\u2019re using <a rel=\"noreferrer noopener\" href=\"https:\/\/httpd.apache.org\/\" target=\"_blank\">Apache HTTP Server<\/a>, you need to create a <code>.htaccess<\/code> file in the <code>public<\/code> folder that looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Options -MultiViews<br>RewriteEngine On<br>RewriteCond %{REQUEST_FILENAME} !-f<br>RewriteRule ^ index.html [QSA,L]<br><\/pre>\n\n\n\n<p>Upload the <code>dist<\/code> files in the public folder.<\/p>\n\n\n\n<h6>Building for Relative Paths:<\/h6>\n\n\n\n<p>By default, vue-cli 3 produces a build, assuming your app is hosted at the server root. To override this, follow the instructions given below:-<\/p>\n\n\n\n<p>Create a <code>.htaccess<\/code> file in the sub directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Options -MultiViews<br>RewriteEngine On<br>RewriteBase \/dev\/<br>RewriteCond %{REQUEST_FILENAME} !-f<br>RewriteRule ^ index.html [QSA,L]<\/pre>\n\n\n\n<p>Open <code>vue.config.js<\/code> file and change the <code>baseUrl<\/code> from <code>'\/'<\/code> to <code>'\/sub-folder\/'<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">...<br>module.exports = {<br>    baseUrl: process.env.NODE_ENV == 'production' ? 'sub-folder' :  '\/',<br>    ...<br>} <br>...<\/pre>\n\n\n\n<p>Change all static assets path with your directory path e.g. <code>\"\/static\/img\/user-1.jpg\"<\/code> with <code>\"\/sub-folder\/static\/img\/user-1.jpg\"<\/code><\/p>\n\n\n\n<p>Add base in the router config file, go to the <code>src-&gt;router<\/code> and open <code>index.js<\/code> file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ session components<br> const SignUpOne = () =&gt; import('Views\/session\/SignUpOne');<br> const LoginOne = () =&gt; import('Views\/session\/LoginOne');<br> const LockScreen = () =&gt; import('Views\/session\/LockScreen');<br> const Auth0CallBack = () =&gt; import('Components\/Auth0Callback\/Auth0Callback');<br> Vue.use(Router)<br> export default new Router({<br>     mode: 'history',<br>     base: '\/sub-folder', \/\/ add here your sub-directory name<br>     routes: [<br>         \u2026<br>     ]<br> })<\/pre>\n\n\n\n<p>Run <code>npm run build<\/code> command.<\/p>\n\n\n\n<p>Upload the <code>dist<\/code> folder files on the sub-folder directory.<\/p>\n\n\n\n<p>For more information, please check the link below:<\/p>\n\n\n\n<p>const Auth0CallBack = () =&gt; import(&#8216;Components\/Auth0Callback\/Auth0Callback&#8217;);<\/p>\n\n\n\n<div class=\"custom-sec-wrap mb-4\">\n\t<a href=\"https:\/\/cli.vuejs.org\/guide\/deployment.html#general-guidelines\" class=\"link-wrap\">\n\t\t<div class=\"content-wrap\">\n\t\t\t<h6>Deployment | Vue CLI<\/h6>\n\t\t\t<p>\ud83d\udee0\ufe0f Standard Tooling for Vue.js Development<\/p>\n\t\t\t<small>cli.vuejs.org<\/small>\n\t\t<\/div>\n\t<\/a>\n<\/div>\n\n\n\n<p>That&#8217;s it, Now your production build will work on the relative path.<\/p>\n<div class=\"pld-like-dislike-wrap pld-template-1\">\n    <div class=\"pld-like-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0);\" class=\"pld-like-trigger pld-like-dislike-trigger \" title=\"\" data-post-id=\"270\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-ip-check=\"0\" data-user-check=\"1\">\n                        <i class=\"fas fa-thumbs-up\"><\/i>\n                    <\/a>\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\n<\/div><div class=\"pld-dislike-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0);\" class=\"pld-dislike-trigger pld-like-dislike-trigger \" title=\"\" data-post-id=\"270\" data-trigger-type=\"dislike\" data-ip-check=\"0\" data-restriction=\"cookie\" data-user-check=\"1\">\n                        <i class=\"fas fa-thumbs-down\"><\/i>\n                    <\/a>\n    <span class=\"pld-dislike-count-wrap pld-count-wrap\">1<\/span>\n<\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>To create a production build you need to run the command npm run build. It will create the dist folder, that contains the production build files. Now you just need to upload the dist files on to the server. Static Server: To run the production build locally, the easiest way to handle this would be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":14,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/pages\/270"}],"collection":[{"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/comments?post=270"}],"version-history":[{"count":10,"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/pages\/270\/revisions"}],"predecessor-version":[{"id":603,"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/pages\/270\/revisions\/603"}],"wp:attachment":[{"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/media?parent=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}