You'll learn how to automate the validation of your scripts using JSLint (or JSHint), concatenate your files using sets of specific rules and finally minify both sets of your output for production use. You'll also learn some additional tips and tricks that can assist you in build file configuration along the way. I hope this screencast comes in useful.
The following are the tools you'll need for today's tutorial. Make sure you follow the Ant installation guide in case additional steps are required. OSX users may find this guide also useful.
- Apache Ant http://ant.apache.org/
- YUI Compressor http://developer.yahoo.com/yui/compressor/
- Mozilla Rhino http://www.mozilla.org/rhino/
- JSLint (https://github.com/douglascrockford/JSLint)
- or JSHint (https://github.com/jshint/jshint/)
- Any text editor
Details: 720p resolution, 21:27m duration. Full-screen mode recommended
What If I Don't Have Time To Watch?
I understand that some of my readers don't have as much time to watch complete screencasts as others do. If you would like to learn how to setup a build process without watching the video, I recommend first installing all of the tools to your local system, then reading through the build.xml file I've put up on GitHub to learn about build file structure. You may need to spend a little additional time researching what particular attributes or tags do, but it will give you a foundation you can build on.
The purpose of this screencast is to introduce readers without a great deal of experience in setting up Ant builds with a primer in this area. So as to keep this screencast as widely applicable as possible, I've kept it server-side language and testing framework agnostic.
Once you understand the basics of setting up an Ant build, integrating additional steps for tasks like unit testing or switching out YUI Compressor for the closure library (or others) become significantly more trivial.I would like for more advanced users to bare this in mind when reviewing the structure of this video.
- HTML5Boilerplate's build script is a great example of an expanded Ant build.xml file. You may also find their use of jpegtran and optipng (for image optimization) in the build of interest.
- Mark Kolich has a useful post up about integrating Ant with Google's Closure compiler if you would rather dive right into setting that up for your build process.
- If looking for a very simplified build script that just focuses on minification, L Corner's build sample may be worth looking at as well.
- I personally like SyntaxHighlighter's build file which also demonstrates variable replacement and license file appending to your files in case you need to re-enforce your licensing conditions
And that's it!. Thanks once again to Aki Karkkainen for being the inspiration behind me recording this screencast. I know a few beginners have found his Ant file templates useful and hopefully this video will further encourage front-end devs to try out both Ant and the other tools listed in today's post. Build processes aren't as scary as they can sometimes appear ; )
If you found the screencast useful, please feel free to share it with your friends or colleagues by clicking the retweet or like buttons below.