SPFx projects are built using a complex Build System that is an npm package. You can find it under node_modules folder under the name - @microsoft/sp-build-web
This package makes use of more packages. You can go into the node_moduels folder and look for packages named @microsoft/gulp-core-build*
The entire build system is built in Object oriented code with lots of classes and interfaces using TypeScript.
If you want to just customize the Build process then you can build custom tasks which are coded in the gulpfile.js.
On good article to learn is at - https://rencore.com/blog/extending-sharepoint-framework-build-process-custom-tasks/