Autobuild SPFx solution
Here today I am sharing a very small & simple script which will save your significant amount of time cleaning -> building -> bundling -> packaging your SPFx solution. To have the final package of the solution I have to enter four commands either on node command prompt or on visual studio code terminal, which are as follows:
- gulp clean
- gulp build
- gulp bundle –ship
- gulp package-solution –ship
But what if we can achieve all these four steps with just double click of the mouse. Let’s see how to do it!
- Navigate to your SPFx solution root folder
- Create a .txt file with any name for e.g. prod-build.txt
- Paste following script in that file and save it as prod-build.cmd
call gulp clean
call gulp build
call gulp bundle --ship
call gulp package-solution --ship
call explorer .\sharepoint\solution\
You are done, just double click the prod-build.cmd file and it will run all four commands and prepare a package ready for you.