The node_modulea and the vendor folder should not be pushed to the server. Those will be downloaded on the server, your deployment script should have the command you mentioned above.
Laravel project size way too big
So, I'm trying to deploy my project to customers VPS - but the project takes way too much space. With node_modules and vendor folders taking around 100MB each, how can I slim it down?
I appreciate any help - googling didn't yield many helpful results, running composer install --no-dev didn't do much to the size.
Yeah, I don't copy them over - but once I run the command above aswell as 'npm install' - it's total size is around 200mb
@jjk but you run the command on the server not locally. So why is it a problem if that directory is that big? You obviously have a lot of dependencies.
Plus the vendor will of course will be big because of the packages. But you don't push those to the repository nor to your server.
The problem is, the whole project after installment is 200mbs. I don't have any extra dependencies other than default laravel + phpmailer and vue.js + dev dependencies that I don't install over.
Here's my package.json:
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.19",
"cross-env": "^5.1",
"laravel-mix": "^4.0.7",
"lodash": "^4.17.13",
"resolve-url-loader": "^2.3.1",
"sass": "^1.15.2",
"sass-loader": "^7.1.0",
"vue-template-compiler": "^2.6.10"
},
"dependencies": {
"node-sass": "^4.13.0",
"vue": "^2.6.10"
}
}
And my composer.json:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.4",
"laravel/framework": "^6.2",
"laravel/tinker": "^1.0",
"phpmailer/phpmailer": "^6.1"
},
"require-dev": {
"facade/ignition": "^1.4",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^8.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\Foundation\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}```
@jjk and you know that all of them have their own dependencies right? :)
Yes, I do - but my point is - how much does laravel + vue.js + required essentials weight in total? I was hoping it's not 200mbs.
I don't know the actual size, plus that one might change every single day as new releases are being published from all the libraries.
Is the size really a problem? Digital Ocean for example gives you 25GB of space for 5$ a month, as far as I remember.
Well, my customer is complaining - that's about it really.
Guess he'll have to deal with it.
@jjk It depends what packages and libraries you’re installing. Obviously the more packages and libraries you install, the more disk space that will take (as packages and libraries will have their own dependencies, and those dependencies will have dependencies, and so on).
If disk space really is of a concern, then run some diagnostics on file sizes and try and find large files. You might have packages that have came with art assets (PSDs, PDFs); compiled binaries; language files for multiple locales; seeds and fixtures for testing; and so on.
@martinbean the OP probably has moved on in the last 2 years????
@tykus Bizarre. It was showing near the top on the front page when I replied 😕
@martinbean probably a spam reply was removed... 🤷♂️
Please or to participate in this conversation.