Skip to content

Build Script Wizard

cust0dian edited this page Feb 27, 2012 · 6 revisions

This tool was created to walk you through using the build script.

Get Started

First things first...

Requirements

If you're on Mac or Linux...

You've got all your dependencies pre-installed, likely. You may need a yum install ant-contrib or what have you.

If you're on Windows...

  • Get the Java JDK (JRE isn't enough)
  • Get WinAnt and point the installer to Program Files/Java/jre6/bin/

Next Step

Which added tool are you using?

Go Back

Using the Build Script

  • 1) Mac users, open the application "Terminal". Windows users, open command line interface by doing Start Menu > Run > cmd.exe. However, Windows users, we created a friendly runbuildscript.bat file for you if you'd like to avoid the command line and navigate to the build directory within your project.

For those of you new to terminal or command line, use the change directory command followed by the directory path. for example...

cd sites/your-site/build/

Note: To ensure you've navigated to the correct directory, you may want to now check the files within the current directory. Mac users can type "ls" in terminal. Windows users should type "dir" in command line. If the file list returned is what you were expecting, move to step 2. Otherwise, check the directory location in Finder or Windows Explorer and start over.

  • 2) Next, simply type:
ant build

The H5BP build script will begin to run and compress your files. At the very end you should see "BUILD SUCCESSFUL" followed by the total time it took to build.

  • 3) Now, look in your H5BP project folder and see that there is a newly created "publish" directory within your project. Inside, you will find your minified CSS, JS and along with duplicates of the files from your original directory. This new set of files within "publish" is your production code. The site should look and function the same in browser as it did before, but only now faster!

Note: If your new pages do not render in browser the same as they did before your ran the build script, click here (see Troubleshooting at the bottom).

Going Further

There are a few different build options:

ant build     # minor html optimizations (extra quotes removed). inline script/style minified (default)
ant buildkit  
# all html whitespace retained. inline script/style minified
ant basics    
# same as build minus the basic html minfication
ant minify    
# same as build plus full html minification
ant text      
# same as build but without image (png/jpg) optimizing

Go Back

Wordpress integration

Check out Jay George's wordpress screencast videos: http://www.jaygeorge.co.uk/1-html5-buildscript-wordpress-1/

Using the build script on a Wordpress theme introduces a significant problem: Wordpress themes are installed to a website's /wp-content/themes/<theme-name> directory while the build script's output references the minified/concatenated files in a relative URI as js/scripts-xxxx.min.js. Therefore, output of the build script will reference files in the wrong location.

To make the build script output files that reference the correct url /wp-content/themes/<theme-name>/js/scripts-xxxx.js, the build.xml file must be modified. Edit the 2 regular expressions near lines 599 (for js) and 699 (for css) to include the Wordpress PHP that dynamically references the theme's folder: (the line to add is indented)

<replaceregexp match="&lt;!-- scripts concatenated [\d\w\s\W]*?!-- 
end ((scripts)|(concatenated and minified scripts))--&gt;"

replace="&lt;script src='
    &lt;?php bloginfo('template_url'); ?&gt;/
${dir.js}/scripts-${build.number}.min.js\'&gt;&lt;/script&gt;"
flags="m">

That's all.

Go Back

Cake

There's nothing here.

Go Back

Rake

There's nothing here.

Go Back

<script type="text/javascript"> $(document).ready(function(){
// show first panel
$("#panel-1").fadeIn();

// navigation
$(".nav").click(function(){
	var href = $(this).attr("href");
	$(this).parents("section").fadeOut(function(){
		$(href).fadeIn();
	});
});

}); </script>

Clone this wiki locally