Laravel 5.4 go live with no npm installed - laravel-5

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.

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 do I deploy an SSR NuxtJs app to a host

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.

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.

Laravel mix, unable locate mix file: /css/xxxxx.css during npm run production

When I finished my task, I didn't commit webpack packaged assets such like CSS, JS, only commit /resources/assets/* to git, and pull the commits on the production machine, during it packing js and CSS it needs a little time to minify CSS and js.
At this time many user request the page, and some page include CSS such like <link rel="stylesheet" href="{{ mix('/css/xxxxx.css') }}"/>
will cause an exception in the log like Unable to locate Mix file: /css/xxxxx.css
How can I avoid this happened?
Running composer install or npm run prod on a production server which is not in maintenance mode is not adviced. If you need a zero-downtime deployment, take a look at Envoyer. It's made by the same person who created Laravel.
On a side note, running npm run prod on a production server is not adviced, even if you use envoyer. There is no point in having all your node files on the server and you'll be wasting unnecessary server processing power by running node commnds. I'd recommend running node commands on your local machine and pushing the final compiled files that webpack spits out to the server. Anyways, you need to check if the production version of your CSS and JS work as intended on our local machine before deploying it to the server.

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

Resources