Have you checked if the custom or normal style.css file is imported correctly?
Laravel Deployment
Hello
I just deployed my first laravel site. I am doing so on digital ocean on a droplet with nginx.
I am encountering a problem. The styling is all of a sudden messed up. In local development it was styled correctly, but online its messed up. I am using Tailwind but also normal CSS classes.
Does anyone know what that could be. I did run npm run build before launch.
Thanks in advance
Are the styles messed up in your local development after the build? The build step purges out any tailwind classes that it thinks aren't used in you app.
Hello, use this commands before make zip for deploy
- php artisan clear-compiled
- php artisan route:clear
- php artisan config:clear
- php artisan view:clear
- php artisan cache:clear
- php artisan optimize
[!TIP] You can also write this code in routes/web.php and then access to these commands from browser after deployed... for examp. domain.com/clearservices it will run first command
// Clear Compiled Services:
Route::get('/clearservices', function() {
Artisan::call('clear-compiled');
return 'Application services has been cleared';
});
// Application Route Clear:
Route::get('/routeclear', function() {
Artisan::call('route:clear');
return 'Application optimized';
});
// Clear Config Files:
Route::get('/configclear', function() {
Artisan::call('config:clear');
return 'Application optimized';
});
// Clear View Files:
Route::get('/viewclear', function() {
Artisan::call('view:clear');
return 'Application optimized';
});
// Clear application cache:
Route::get('/clearcache', function() {
Artisan::call('cache:clear');
return 'Application cache has been cleared';
});
// Application optimize:
Route::get('/optimize', function() {
Artisan::call('optimize');
return 'Application optimized';
});
// CACHING------
// Clear application cache:
Route::get('/clearcache', function() {
Artisan::call('cache:clear');
return 'Application cache has been cleared';
});
//Clear route cache:
Route::get('/routecache', function() {
Artisan::call('route:cache');
return 'Routes cache has been cleared';
});
//Clear config cache:
Route::get('/configcache', function() {
Artisan::call('config:cache');
return 'Config cache has been cleared';
});
@iamgeorge @danieljohan Never do this. Public endpoints that anyone can call to control the application cache is a horrible idea.
Hello, use this command before make zip for deploy
You should use a version control system like git, not zips. Host the code in an online repository and deploy changes from there. GitHub is the most popular platform for this.
@JussiMannisto Once the deployment is finished, the endpoints can be removed from web.php. Regarding version control systems like Git, I can say that using a zip file for deployment isn’t necessarily a bad idea, depending on whether the deployment process is done correctly.
@iamgeorge can you hear yourself? How do you remove the routes without re-deploying? Unless you are suggesting editing the files on the server (shudders)?
Regarding version control systems like Git, I can say that using a zip file for deployment isn’t necessarily a bad idea, depending on whether the deployment process is done correctly.
If you don't use any version control and use zips to deploy code changes, it's safe to say you're not doing it "correctly." There's a reason why everyone uses version control.
@Snapey yes that's exactly what I meant, editing one file on the server is not Armageddon ))
@JussiMannisto If I have finished the local development process 100%, then it's okay to deploy without version control. I would say that version control is not mandatory; it depends on the type of website. There are also reasons why you might choose not to use version control. and one more editing one file after deploying on the server is not Armageddon
@iamgeorge ok, learn the hard way
@Snapey Yes, I agree with you this is sometimes really "hard way", but in this case, the problem is that the styling is messed up after deployment. I’ve had a tough time with styling issues on different hosting platforms. Preparing the app before deployment sometimes doesn’t work, and after deployment, it often requires running some additional commands. A quick solution is to add those commands temporarily and then remove them afterward. I understand the benefits of version control, but this is just about correcting styling, not making general changes to the whole website. I am still learning, and I don’t think I can ever say that I know everything. However, based on my experience, this approach works well. Thank you also for sharing your experience.
I would say that version control is not mandatory
@iamgeorge You‘re just trolling now…
@martinbean listening to me, I have no time for this/you, that's all... I know, now you understand me well, have a nice day.
@iamgeorge No, I imagine you don’t have time. I imagine you have busy day ahead preparing a folder for uploading, and then running Artisan commands via URLs instead of deploying automatically via a CI pipeline from a source repository 🙃
@martinbean ok, you are right 😇
Open the browser development tools, network tab, and refresh the page. Any missing assets will be in red.
A possible cause is not hosting your site correctly. When you open your page is the path the same (apart from the domain) or do you have to add aditional folder(s) ?
If you are building your js and CSS files locally then pushing them to your git repository, make sure that the build directory is not in the .gitignore file
@danieljohan I imagine it’s because your website is being served as HTTPS, but your assets have HTTP URLs. If this is the case then you need to configure proxies for your app so that it can correctly detect it’s running under HTTPS and generate HTTPS URLs:
https://laravel.com/docs/requests#configuring-trusted-proxies
Hello Guys,
Thank you very much. All responses are highly appreciated.
Well, I did use git with bitbucket, I didn't know though that I could use it to even pull on my droplet, thanks @jussimannisto
So I configured it with ssh and stuff, I pulled it on my droplet, it took me a matter of seconds, while with FileZilla I was waiting 10 minutes. This is awesome stuff. So now its up and running. then With a few commands from @iamgeorge like clear-compile and stuff and know it runs nicely!!
Awesome stuff ... Thanks again guys!
Please or to participate in this conversation.