Reputation: 179
When I build my React app using npm run-script build
there are a folder and a file that I don't want to be there.
Is there a way to ignore the file and the folder during the npm run-script build?
I know there are the .gitignore and the .npmignore but there are used to ignore the files only for the publication (not the build).
Thank you.
Upvotes: 7
Views: 13841
Reputation: 545
I know it's a pretty old thread, but like I faced recently this problem, so I think this might help others.
Like Thottle mentioned in a comment, using rm -rf ./filePathToExclude
pattern in build scripts can help. The only change that worked for me was to put rm -rf /.filePathToExclude
before react-scripts build
.
The final build script that worked for me (for excluding .env file, that is in the same directory as package.json) was rm -rf ./.env && react-scripts build
.
Upvotes: 6