This little script saves me thousands of keystrokes and hours of wasted time while building SPFx (SharePoint Framework) solutions. Generating a production level build is one of the most annoying parts of building SPFx solutions. In the Visual Studio world we could just hit a button and BAM! a package shot out the other end. Well, that is not entirely the case with SPFx. First I have to ‘gulp clean’ then ‘gulp build’ then ‘gulp bundle’ then ‘gulp package-solution’ then go to the folder. This gets old quick, at least for me it did. There were a few ways I tried to fix this and the simplest way was to make a batch file that would call all the commands. I’m sharing this with you so that you don’t have to do any experimentation or try writing your own.



New call-to-action


call gulp clean

call gulp build --ship

call gulp bundle --ship

call gulp package-solution --ship

call explorer .\sharepoint\solution\

Put this file in the root of your SPFx project and run it in the command line. Of course you have to watch for errors. This is something I usually run one I know i have a clean + working build. Don’t forget to increment your build numbers 🙂 Happy coding!

  • pooja
    Posted at 9:31 pm August 22, 2019

    Hi Tom,
    So glad that i also have created this initially to save my time but i have created .bat file instead of cmd file .

  • Leave a Reply to pooja
    Cancel Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.