I configured my gulpfile.js to do just three things:
- Concatenate all files from a set directory into one file and put it in the build folder
- Minify the resulting JavasScript
- Rename the file, changing the extension to .min.js
Everything was working great. By simply running 'gulp app-build' from the command line I could produce a nice small file, perfect for a snappy web experience.
However, I came across some serious issues when trying to deploy the project to production. I tried adding Gulp to my Kudu deployment script like I had done to load my npm modules. I was frustrated when despite my insistent hacking (which went further into the early hours of the night than I would like to admit!) I kept getting the following error or similar:
When I came back to revisit this problem during a sensible time of day, I discovered my mistake.
This issue on Github was a particular givaway. My thanks to Matheiu Swiip. I had incorrectly assumed that gulp was a tool that I could make a part of my build.
UPDATE:
Having spoken to a colleague about this, it turns out that you can in fact use gulp as part of the build. But any dependencies marked as "dev-dependencies" in the npm package file. So all I need to do is move the ones I need for my build into the main "dependencies" area.
I don't think that anybody doubts the reasons for minfying JS files. But in case anybody is interested, this is the difference it made to my AngularJS app:
We start with:
And after minfication:
At 938KB and 123KB we can see that AngularJS itself is the biggest file.
When finally I got gulp working properly in my production environment and I had concatenated and minified my dependencies things started looking really peachy:
No comments:
Post a Comment