Reputation: 21
I'm doing the fullstackopen course. There's a part where you create the production build files of a React application and copy them to the backend directory so that they can be served as static files. To optimize the task, they suggest adding this npm script to the backend directory:
"build:ui": "rm -rf build && cd ../../osa2/materiaali/notes-new && npm run build --prod && cp -r build ../../../osa3/notes-backend/",
If I understand correctly, this removes the build folder from the backend, then changes directory to the frontend where it creates a new production build and then copies the folder to the backend. But what is the --prod
flag doing? I made a small test, running npm run build
and npm run build --prod
and the output seems to be the same.
Upvotes: 2
Views: 7048
Reputation: 93
Seems like that the --prod
flag is ignored during builds. You need to call the build command as npm run build -- --prod
. The extra “--“ makes sure the --prod
flag is passed.
Upvotes: 3