Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create-react-app and large Heruko Slug Size?

Tags:

reactjs

heroku

I am developing a Front-end Application and hosting via Heruko

The Problem is that the slug size is too large when i investigated the issue I find out there is files like

/node_modules
/build
/src
/public
package.json
package-lock.json
tsconfig.json
README.md

Image

The Official document says to use .slugignore file but the problem is that i need to use src and other files in build process I have found a solution for that but using this heroku-buildpack-post-build-clean

when i tried it i am able to remove

/src
/public
package.json
package-lock.json
tsconfig.json
README.md

if i remove the /node_modules the Application Just Crash

enter image description here

my scripts inside package.json file

"scripts": {
  "heroku-prebuild": "npm install -g serve",
  "devstart": "react-scripts start",
  "start": "serve -s build",
  "build": "react-scripts build"
},

now the file size is 465MB

enter image description here

can anyone knows how to safely remove /node_modules or how to better Do it.

the /node_modules size is larger than 410MB

Thanks in Advance

like image 691
Muhammad Usama Ashraf Avatar asked Oct 27 '25 11:10

Muhammad Usama Ashraf


1 Answers

I am able to solve it using

heroku-buildpack-post-build-clean

and using .slug-post-clean file

src
public
README.md
node_modules

I need package.json file only on heruko with build folder

Now the slug size is 57.9 MB that is 400 MB less

Heruko Slug Size

like image 152
Muhammad Usama Ashraf Avatar answered Oct 30 '25 00:10

Muhammad Usama Ashraf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!