How do I deploy an SSR NuxtJs app to a host - production-environment

I'm coming from the SPA / React world and am working on my first Nuxtjs SSR app.
When I run an npm run build I'm expecting artifacts to be created which can be copied over to my production environment that are then run using node on the server. When I do an npm run build, I get nothing in a dist folder but in ./nuxt/dist there are two folders, server and client.
Completely lost on how to proceed from there. All the online help seems to be for non production builds with the entire development folder present to run nuxt start.
How do I do a production deployment and run it using node on a server

There are several way to publish nuxt:
So, for an SPA deployment, you must do the following:
Change mode in nuxt.config.js to spa.
Run npm run build.
Deploy the created dist/ folder to your static hosting like Surge, GitHub Pages or nginx.
but I think you use universal mode (SSR) so in this mode its better to install npm or yarn in server and run this command in your production server
nuxt build
nuxt start
So if you want to copy dist folder change mode of project to SPA in nuxt.config.js
For more information read this article
How do I deploy an SSR NuxtJs app to a host

There is the same question with my answer. There you will find necessary configs, so I do not want to copy the answer here, because it is better to keep everything in one place because of possible updates.

Related

Laravel + Vue js Deploying on Shared hosting

I have a Laravel project that already deployed on shared hosting server but now I just want to add Vue.js component to that project.
Problem is when I was deploying project I didn't install the npm. Can anyone advise me how to fix this thing. I used Laravel 5.8
How can I add Vue component to this project ?
you can't run npm commands in sharing hosting .
you can run npm run production in local and share mixed file on sharing hosting
Usually shared hosting does not provide enough shell commands. So you would need to run npm run production on your local computer.
As a reminder, it is not recommedable to host Laravel website on a shared host. You may need to do extra work to make your Laravel website work such as changing document root of your laravel project.

How to run a Jenkins CI with cypress e2e test for Vue SPA that has to connect to Laravel APIs?

I am trying to set up Cypress end-to-end tests for a Vue SPA application that has to connect to a Laravel backend; the tests are to run in a Jenkins pipeline. This is practically straight forward in a local development environment. Basically:
Use docker-compose to spin up Laravel and DB
Use docker to spin up the SPA and then exec cypress run inside the container
However, I can't seem to think of an optimal way to set up something like that in a Jenkins pipeline. The SPA and Laravel are in separate repositories and I do not want to pull the one into the other while running the CI process; the thought itself seems messy.
So, basically, what is an optimal way to set up a Jenkins pipeline that does end-to-end cypress tests for a Vue SPA that has to connect to a Laravel API/MySQL DB?
This is my very first SO question and I apologise in advance if there are any rules I breached while creating it.
Cypress does not care where your BE is being hosted, it is set by your baseUrl.
Set up a deployment process for your BE repo on your Jenkins CI, which hosts the site at a subdomain of your ci server like e2e.example.com. Once your BE is deployed, then you can setup another job to deploy and test your Vue SPA.
If it was me, I would create one job and have it deploy first the latest/specified version of your BE, then deploy the frontend and run cypress. I have done this on an older project, with capistrano and jenkins and cypress, however mine was not an SPA in two repos so I did not have to do both deployments in one job.

Deployment of Laravel app with Vue component on shared hosting - vue components are not displaying

I'm testing process of deploying app with vue components on shared server. I have access to ssh. Npm is also installed. I check it with "node -v" command. The problem is that vue compoennts are not displaying. I tried to write "npm run production" but I receive an error 126. What should I do to display vue components? I know the voices that shared hosting is not the best choice but I'm just testing. I know that it's possible to turn on vue components on this hosting. I did it long time ago but I forgot how. My process of deployment had 3 steps:
1. Copy files (wihout public_html) from local disc to shared server w
2. Copy public_html do public_html on shared server
3. Changing paths in index.php inside public_html
App is almost working. The problem is with vue components. Please help.
You don't need NodeJs in production. You just need to build it (CSS & JS) on your machine, then upload it. Run npm run production in your local machine, then the public/css/app.css and public/js/app.js will be available (depends on your configuration). Then, just upload these files, done.

How to get started in automated deployment

I have an app (built with laravel) which i deployed it and working very well, but i have a question, when i deploy it the server i made these process :
1- minify css and js files and comine them in a single file
2- changing some configuration (database,hostname,mail sever ,etc ...)
3- Finally i upload my files to the server.
how can i return back to my local config and unminify my js and css files without doing it manually ?
is there a better way to make it automated ? i know that the first step can be done by gulp or any javascript task runner by a single command and the second one is not a big deal ,but i just want to know if there an automated way?
Why don't you just have a .env config file out of you version control and compress your CSS/JS using Laravel Mix as a part of your deploy process?
To make it clear:
Keep your .env file in .gitignore. Thus you have to setup your environment settings only once (database, hostname, etc).
Use npm run prod to minify your CSS/JS: https://laravel.com/docs/5.4/mix

Laravel 5.4 go live with no npm installed

I've just finished my first project with laravel.
Now when I want to go live, I suddenly discovered that my host does not allow installation of nodejs on their shard host package.
The shock the horror....
I managed to do everything on the live server, I ran npm run production on my local machine and uploaded the minified files for the css and js.
The problem is, on my shard server, I still get this vue warning:
You are running Vue in development mode. Make sure to turn on
production mode when deploying for production. See more tips at
https://vuejs.org/guide/deployment.html
but not on my local machine.
Looking at the link they refer to, I don't really understand what I need to do as I'm new to laravel, npm, node and vue.
How can I turn vue to production mode manually without npm?
Is it possible?
Yes, you can adjust this manually. If you are using the Laravel scaffolding for Laravel Mix, add the following lines to your resources/js/bootstrap.js file
Vue.config.devtools = false
Vue.config.debug = false
Vue.config.silent = true
These lines will suppress the warnings, debugging and turn off devtools, essentially the same as npm run production. This will also turn them off in your local environment, but it is probably your only solution.

Resources