Muhammad Usama Ashraf
Muhammad Usama Ashraf

Reputation: 564

create-react-app and large Heruko Slug Size?

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

Upvotes: 4

Views: 1209

Answers (1)

Muhammad Usama Ashraf
Muhammad Usama Ashraf

Reputation: 564

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

Upvotes: 9

Related Questions