Git Product home page Git Product logo

ant-build-script's Introduction

The Ant Build Script is a tool that optimizes your code for production use on the web.

It's designed to work with HTML5 Boilerplate with minimal configuration, but it's also here to serve as a rich source of Ant tasks you can use as the basis for your own custom build scripts.

Compatibility

While it should work with any version of HTML5 Boilerplate (with varying degrees of intervention) v1.0 of the Build Script was developed and tested against v4.0 of HTML5 Boilerplate.

Why use it?

Faster page load times, improved workflow and happy end users :)

What it does

  • Combines and minifies javascript (via Closure Compiler)
  • Inlines stylesheets specified using @import in your CSS
  • Combines and minifies CSS (using YUI Compressor)
  • Optimizes JPGs and PNGs (with jpegtran, advpng & optipng)
  • Basic to aggressive html minification (via htmlcompressor)
  • Revises the file names of your assets so that you can use heavy caching (1 year expires).
  • Updates your HTML to reference these new hyper-optimized CSS + JS files
  • Updates your HTML to use the minified jQuery instead of the development version
  • Remove unneeded references from HTML (like a root folder favicon)
  • Runs your JavaScript through a code quality tool like JSLint or JSHint (optional)
  • Runs your CSS through a code quality tool, CSSLint (optional)
  • Cache-busting support for a module directory
  • Optionally precompile LESS formatted CSS
  • Optionally precompile SASS formatted CSS
  • Optionally output JSDOC3 documentation
  • Optionally convert your JPGs to progressive JPGs
  • Optionally validates your HTML
  • Optionally set your script to use async or defer

Add the build script to your project

For most people, you can just drop the contents of the build script repo into your HTML5 Boilerplate project in a build folder. That's the easiest way to get up and running.

Add the build script to your project (Advanced version)

Since we split out the build scripts from the main h5bp repo, you now have more options on how to integrate a build script into your project.As was mentioned you can simply drop the contents of the build script repo into a build folder and you're good to go.

If you'd like to merge it into your main HTML5 Boilerplate repository and preserve the build script commit history (and the ability to update from Github), alongside the H5BP commit history, please follow this workflow:

# Move into your project's git repository
cd my-project
# Create and checkout a new feature branch
git checkout -b ant-build-script
# Create a new remote called "h5bp-ant-bs".
# Fetch the build script from the remote repository.
git remote add -f h5bp-ant-bs git://github.com/h5bp/ant-build-script.git
git merge -s ours --no-commit h5bp-ant-bs/master
# Put the build script into a subdirectory `build/`
git read-tree --prefix=build/ -u h5bp-ant-bs/master
# Commit the merge (preserve the build script history too)
git commit -m "Subtree merge H5BP ant build script"
# Update the build script subtree if needed
git pull -s subtree h5bp-ant-bs master
# Merge back into master branch if everything went according to plan

Requirements

Out of the box, the build script requires Java 1.6.

Ant itself requires the Java JDK, version 1.4 or later. 1.5 or later is strongly recommended.

Closure Compiler, our tool for script minification, requires Java 1.6.

This means that OS X versions prior to 10.6 are no longer supported out of the box. SoyLatte provides 10.4 and 10.5 builds of OpenJDK 7 for Intel OS X machines. However, only OS X 10.5 builds of OpenJDK 7 are available for PowerPC based Macs due to a bug in the 10.4 Compiler. (Be sure to read the Download link as the archives are password protected "to provide a click though agreement" of the JDK licensing.)

Alternatively, YUI Compressor, which requires Java > 1.4, could be swapped out for Closure Compiler.

Quick Start

You must wrap any scripts to concatenate in a pair of specially constructed comments. These look like this:

legacy version (pre 1.0) (https://github.com/h5bp/ant-build-script/wiki/What-version-are-you-running%3F)

    <!-- scripts concatenated and minified via build script -->
    <script src="js/plugins.js"></script>
    <script src="js/main.js"></script>
    <!-- end scripts -->

1.0 and greater

  <!-- //-beg- concat_js -->
  <script src="js/plugins.js"></script>
  <script src="js/main.js"></script>
  <!-- //-end- concat_js -->

If you're on Mac or Linux...

You've got all your dependencies pre-installed, likely. You need to install ant-contrib to get the build script working.

On Linux use yum install ant-contrib.

On Mac, install MacPorts and then do sudo port install ant-contrib.

You should test what version of optipng you have. IF it's less than 0.7.0 then you need to uncomment line 189 of project.properties.

If you're on Windows...

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.

    1. 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.

    1. 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, visit the Troubleshooting section below.

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

Your build will be added to the publish/ folder. BOOM! you're done.

ant-build-script's People

Contributors

akavlie avatar alvincrespo avatar andreas-marschke avatar andrewle avatar chuanxshi avatar cwmrowe avatar darktable avatar dholth avatar drublic avatar gbakernet avatar git2samus avatar glsee avatar gmoulin avatar joemorgan avatar johnbacon avatar kblomqvist avatar kushalp avatar mdonoughe avatar morficus avatar paulirish avatar rdeknijf avatar rikkert avatar robbyrice avatar roblarsen avatar rrelmy avatar simensen avatar slindstr avatar tarciosaraiva avatar timemachine3030 avatar ziggys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ant-build-script's Issues

Leading Slash For .js Files Prevents Concat

Hi,

If a leading slash is put into index.html, the file no longer concats. Related to the changes for #43.

Build Works:

<script src="js/main.js"></script>

Build Doesn't Work:

<script src="/js/main.js"></script>

With the error:
[concat] /js/main.js does not exist

<filelist> is ignoring the dir property in this case.

http://ant.apache.org/manual/Types/filelist.html says wildcards will be added to the list "unchanged"...so it's considering a leading slash a wildcard maybe?

The following (Line 502-504) works for me, but there's probably a less verbose way of solving the problem.

      <for list="${scripts.ordered}" param="file" delimiter="${line.separator}">
        <sequential>
          <propertyregex property="file.clean" input="@{file}" regexp="^/?(.*)" select="\1" override="true"/>
          <if>
            <isset property="files.toconcat"/>
            <then>
              <var name="files.toconcat" value="${files.toconcat},${file.clean}" />
            </then>
            <else>
              <var name="files.toconcat" value="${file.clean}" />
            </else>
          </if>
        </sequential>
      </for>

      <filelist id="scripts.toconcat" dir="./${dir.intermediate}/" files="${files.toconcat}">
          <file name="${dir.js}/plugins.js"/>
      </filelist>

Thanks

Manifest gets wrong paths with sub-directories in build process

orignally raised in Mobile Boilerplate, h5bp/mobile-boilerplate#106, manifest gets wrong paths with sub-directories in build process.

In the Mobile Boilerplate case, the issue was fixed with hardcode support for sub-directories. We should see if the build.xml can be improved with support of arbitary subfolders under images.

Steps to reproduce:
Set site manifest creation on in build/config/project.properties:
file.manifest = manifest.appcache

Build project:
cd build && ant build

After building the project the manifest file in publish/manifest.appcache has the following image files listed:

# image files
img/startup.png
...
img/apple-touch-icon.png
img/apple-touch-icon.png
img/apple-touch-icon-precomposed.png
img/apple-touch-icon.png

The real paths of the icons are:

img/h/apple-touch-icon.png
img/l/apple-touch-icon.png
img/l/apple-touch-icon-precomposed.png
img/m/apple-touch-icon.png

Java exception during js.minify

While running the build script I'm getting the following error:

-js.all.minify:
[echo] Minifying scripts
[copy] Copying 2 files to /Users/Josh/Server/lee-drugs/intermediate/js
[apply] Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
[apply] at java.lang.ClassLoader.defineClass1(Native Method)
[apply] at java.lang.ClassLoader.defineClass(ClassLoader.java:676)
[apply] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
[apply] at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
[apply] at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
[apply] at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
[apply] at java.security.AccessController.doPrivileged(Native Method)
[apply] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[apply] at java.lang.ClassLoader.loadClass(ClassLoader.java:317)
[apply] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
[apply] at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
[apply] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:375)
[apply] Result: 1
[apply] Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
[apply] at java.lang.ClassLoader.defineClass1(Native Method)
[apply] at java.lang.ClassLoader.defineClass(ClassLoader.java:676)
[apply] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
[apply] at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
[apply] at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
[apply] at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
[apply] at java.security.AccessController.doPrivileged(Native Method)
[apply] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[apply] at java.lang.ClassLoader.loadClass(ClassLoader.java:317)
[apply] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
[apply] at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
[apply] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:375)
[apply] Result: 1
[apply] Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
[apply] at java.lang.ClassLoader.d
[apply] efineClass1(Native Method)
[apply] at java.lang.ClassLoader.defineClass(ClassLoader.java:676)
[apply] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
[apply] at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
[apply] at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
[apply] at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
[apply] at java.security.AccessController.doPrivileged(Native Method)
[apply] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[apply] at java.lang.ClassLoader.loadClass(ClassLoader.java:317)
[apply] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
[apply] at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
[apply] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:375)
[apply] Result: 1

Which results in the build failing during -.js.scripts.concat.

I'm guessing this means theirs an issue with some aprt of the script trying to use a version of Java that I don't have. Any ideas?

I'm running the build script on an older PowerPC Mac running 10.5, so that may be the problem.

Ant version check should be greater-than-or-equal, not just equal

BUILD FAILED
build.xml:28: All features of the build script require Ant version 1.8.2.
Please upgrade to 1.8.2 or remove all instances of 'overwrite=no' (and this fail task) from the build script to continue

I have version 1.8.3 installed, but still receive this warning.
I'm assuming exactly version 1.8.2 is not the requirement, just >=1.8.2?

From build.xml:

<fail message="All features of the build script require Ant version 1.8.2. Please upgrade to 1.8.2 or remove all instances of 'overwrite=no' (and this fail task) from the build script to continue">
    <condition>
        <not>
            <contains string="${ant.version}" substring="1.8.3"/>
        </not>
    </condition>
</fail>

Break up the wiki into smaller chunks

There's a lot of detailed content on that one page. It would make sense to break it up a little bit.

For example, the section detailing support for modules is easily big enough to support its own page.

Build breaks HeadJS script loading

Having some issues using the build script alongside the HeadJS script loader.
I noticed support has been included for RespondJS, so hopefully this wouldn't be far from that.

Otherwise, as a temporary solution, how can you prevent forcing versions (hashes)? Also, how do you successfully bypass JavaScript files from concatenation?

Trying to implement repo in h5bp

I am trying to add the repo into my main html5-boilerplate checkout with the instructions in "Add the build script to your project"

When i do

git merge -s ours --no-commit h5bp-ant-bs/master

I get the following error

fatal: 'h5bp-ant-bs/master' does not point to a commit

Missing scripts-concat.min.js?

I'm getting this issue with a fresh clone per the git instructions

-js.main.concat:
     [echo] Concatenating Main JS scripts...

-js.scripts.concat:
     [echo] Concatenating library file with main script file
 [checksum] Could not find file /Users/adamkochanowicz/Documents/Kickstrap/intermediate/js/scripts-concat.min.js to generate checksum for.

BUILD FAILED
/Users/adamkochanowicz/Documents/Kickstrap/build/build.xml:143: The following error occurred while executing this line:
/Users/adamkochanowicz/Documents/Kickstrap/build/build.xml:502: Could not find file /Users/adamkochanowicz/Documents/Kickstrap/intermediate/js/scripts-concat.min.js to generate checksum for.

Where is scripts-concat.min.js? I can't find it in any of the folders.

Thanks

include filename/global header to publish output

if you go to cisco.com and look at their .css you can tell they use a buildscript.
I like their output of showing the filename source and header above the minfied css.

cisco.com example snippet:
/*

  • homepage.mb.1.n.min.css
  • $Revision: 1.3 $
    *
  • homepage.mb.1.n.min.css -- aggregated and minified
  • DO NOT EDIT THIS FILE -- edit the individual files and rebuild

/*!

  • BEGIN /web/fw/c/masterbrand_frag/_masterbrand.css
    /body{backg..h:0 1px 1px}/!
  • BEGIN /web/fw/c/masterbrand_frag/_toolbar.css
    /body{backg..h:0 1px 1px}/!

and so on. is there a way to modify the current built script to do something similar?

I see that you can use the <header> inside the concat function, I was able to spit out a global header but I can't make it do the rest of the comments.

right after this line:
<concat destfile="./${dir.intermediate}/${dir.js}/scripts-concat.min.js" overwrite="no">

add this:
<header filtering="no" trimleading="no">
/*

  • DO NOT EDIT THIS FILE -- edit the individual files and rebuild
    */
    </header>

Rewrite relative CSS asset urls when inlining @import calls

Ported from h5bp/html5-boilerplate#689
Originally opened by @craftyshadow

Some CSS frameworks (for example YAML) have a structure where images folders reside with the css, eg:

/yaml/add-ons/microformats/images

If we use the build script to inline the microformats.css file, the relative paths to the images will become invalid. The build script should rewrite relative asset paths on @import inlined files if necessary (ie, the file being inlined is not in the same folder as style.css).

Regex breaks when root.script is in subdirectory

Maybe I am just doing it wrong, but when I specify my root script in a subdirectory, like this:

file.root.script = path/to/my/root/script.js

This regex:

<var name="matchRegex" value="&lt;!-- scripts concatenated [\d\w\s\W]*&lt;script.*src=['&quot;]?(.*)/${file.root.script}(?:\?.*)?['&quot;]?\s*&gt;\s*&lt;/script&gt;[\d\w\s\W]*&lt;!-- end ((scripts)|(concatenated and minified scripts))\s*--&gt;" />

doesn't do its job and my index.html is not updated with references to the concatenated and minified script file (all the original <script> tags are left in place)

No Stylesheets processed defined in file.stylesheets

Hi

I am new with this item, but I spend almost a day solving this problem about multiple stylesheets.
Finally I failed and now I hope to get some answers here.

In the master description to the boilerplate-ant-build-script you say:
"Combines and minifies CSS --> only tweak the project.properties "file.stylesheets".
I assume, with this introduction, there should be some code prepared in the download of the build-script.

I put in my stylesheets in "file.stylesheets", but the only stylesheet processed was the hbp5-stylesheet file.root.stylesheet = style.css. All other stylesheet were copied 1 by 1 to the publish-folder.

I studied the code of the built.xml quite intensive and in fact, I couldn't find ANY code in the build.xml to concatenate the additional stylesheets, mentioned in the "file.stylesheets". All code in the target "-css" only deals with the file.root.stylesheet = style.css.

Question:

  1. Is there really no code to concatenate the additional stylesheets, mentioned in the file.stylesheets?
    If yes, is this mistaken or correct? The introduction makes me assume it should be out of the box.

  2. Can somebody please send me the possible missing code?

Best regards in advance from Germany
Gernot

jQote templates break build script

Ported from h5bp/html5-boilerplate#899
Originally opened by @aaronsnoswell

Using a jQote template of any sort within markup seems to break the build script - htmlcompressor apparently parses the file successfully, but the suspect output html file will be empty. Caused me lots of headaches wondering what was going on. I suspect it is something to do with the <![CDATA[ ... ]]> tags that jQote templates require. AFAIK they are valid HTML though. Seems to be a bug in htmlcompressor? To reproduce:

  1. Create a new html5 boilerplate project using createproject.sh
  2. Replace index.html's content with this markup.
  3. Run the build script

Interactive Tasks to Prompt for Configuration Information

from: h5bp/html5-boilerplate#867

Here are random thoughts and ideas on the build scripts. I think it could apply to both the ant and cake version.

The idea here is to make the scripts easier to work with, guiding the user along the way and prompting for the more common configuration values.

The more I think about it, the more I see this as some kind of wizards, maybe related to #796. The docs and guiding could be part of the build script itself. Might be a terrible idea though, but I'd like to hear other thoughts on this. Users may configure how the build script behaves without editing configuration files.

What I can think of is

some of the directory paths (like source, publish, js paths, css and images).
the list of html pages to process
probably other options like file.root.script and file.root.stylesheet

Each of these prompted values would have a description and a default value (most likely from default.properties). We may think of using the project.properties file to store these values.

For ant, the input task may be used to do this.

Support for 1.8.3?

When I had problems with Winant, I installed Ant myself manually. I installed Ant 1.8.3 (the latest version) from ant.apache.org and had problems with the build script. Specifically the problem was this error message:
"All features of the build script require Ant version 1.8.2. Please upgrade to 1.8.2 or remove all instances of 'overwrite=no' (and this fail task) from the build script to continue"

Which I believe is caused by this snippet in build.xml (Initializr) :

<fail message="All features of the build script require Ant version 1.8.2. Please upgrade to 1.8.2 or remove all        instances    of 'overwrite=no' (and this fail task) from the build script to continue">
<condition>
<not>
<contains string="${ant.version}" substring="1.8.2"/>
</not>
</condition>
</fail>

Improving support for AMD/RequireJS

I've been testing a few different AMD frameworks lately, and it makes sense to move towards require.js (and similar solutions). Since there's already a starting point with require.js support in Ant-Build-Script, it's worth approaching a build that cachebusts without breaking modular integration. Referencing my previous issue raised in regards to head.js - Issue #26.

require.js has some handy features that will make this task significantly less complex, for example multiversion functionality is built in. The logic would ideally expect some level of proficiency with and understanding of require.js, so does not need to be built in as a default (similar to the existing require.js solution). The build script would, in theory, only need to update (a) the main script file referenced in the <script> tags and (b) a version defined in the main script file.

Sounds simple enough, right? :)

optiPNG and metadata

Hi,

As we said in a html5-boilerplate repo issue, optiPNG is great but can't, till now, stripped metadata.

Great news ! OptiPNG 0.7 is out and -strip option is well here :) So metadata can now be stripped.

Generate Source-Map w/ Closure Compiler

Do you think it's useful and possible to integrate the building of a source-map for JS-Files with Closure Compiler as described over here?

I think this is very helpful for everyone using the Ant Build Script.

Multiple folders for dir.images

Multiple folders now crashes the build script. Is there a way to include multiple folders in a comma separated form like file.pages?

js/main.js doesn't get minified/concatenated

I've just swtich to the new js folder structure/name conventions, and I've noticed that main.js isn't minified/concatenated in publish/js/ (only plugin.js gets minified there).
Reading the sources I've tried to put back the index.html (that wasn't needed since I moved the template in other files) file and now it works.
Since I prefer to delete that file (I'm using index.php), is there a way to do it safely without breaking the build script?

createproject.sh confused on directories

Using merged-in repo via instructions + a 'git merge ant-build-script' from master branch (which is h5bp)

[swiftone@mybox build]$ pwd
/home/swiftone/projs/html5-boilerplate/build

[swiftone@mybox build]$ git rev-parse --show-toplevel
/home/swiftone/projs/html5-boilerplate

[swiftone@mybox build]$ ./createproject.sh
ERROR: Project already exists at .///

[swiftone@mybox build]$ ./createproject.sh builddemo
Created Directory: .//builddemo/
cp: cannot stat .//css': No such file or directory cp: cannot stat.//js': No such file or directory
cp: cannot stat .//img': No such file or directory cp: cannot stat.//build': No such file or directory
cp: cannot stat .//*.html': No such file or directory .//build.xml' -> .//builddemo/build.xml' .//project.xml' -> .//builddemo/project.xml' cp: cannot stat.//_.txt': No such file or directory
cp: cannot stat .//_.png': No such file or directory cp: cannot stat .//*.ico': No such file or directory
cp: cannot stat`.//.htaccess': No such file or directory
Created Project: .//builddemo/

[swiftone@mybox build]$ ls
builddemo build.xml config createproject.sh project.xml readme.md runbuildscript.bat tools

(also notice \t characters below)
[swiftone@mybox build]$ ./createproject.sh -h
./createproject.sh (c) 2011 by Rick Waldron & Michael Cetrulo version 1.0
USAGE: ./createproject.sh [--src SRC] [--dst DST] NAME
OPTIONS:
--src -s SRC \t set the source directory where your html5boilerplate lives
--dst -d DST \t set the destination directory in which to create your project
--vcs VCS \t make the new location a VCS repository. Currently supported
\t VCSs are: git and hg(mercurial).
--commit -c \t if set will commit the copied h5bp sources into the VCS.
\t this only works with the --vcs option set

If --src is not set it will use the toplevel dir of the current git dir
this behaviour expects that you are in the git repository of h5bp under /build

If --dst is not set it will try to create the directory in the current directory
You can also set the same options in the ~/.h5bprc file
Here are the possible options:
\tsrc\t\t-\tThe source directory from where h5bp is located
\tdst\t\t-\tThe destination in which the new project shoul be created
\twhich_vcs\t-\tThe vcs you want to use
\tcommit_init\t-\tset this to "yes" if you want to commit the contents of the new project
Here is an example for the syntax(It is basically how shell variables are set):

src="/src/html5boilerplate"
dst="
/src"
which_vcs="git"
commit_init="yes"

(Shell details if it's relevant)
[swiftone@mybox build]$ echo $SHELL
/bin/bash

[swiftone@mybox build]$ bash --version
GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

modules not working

The modules feature does not seem to work properly.

I have two files in js/modules and one of my html files refers to them (after the scripts block).

When I do ant build, the references are rewritten as expected: src= js/nnnnnnn/filename.js etc. The build directory has the expected directory of nnnnnn, but is empty. The intermediate directory has a nnnnnnn subdirectory with the two unminimised files.

The javascript in the modules directory has also found its way into the main minimised js file.

So, two glitches I think. I'm not an ant expert so I can't see where the problem is so I'd appreciate a fix.

Many thanks

HTML Compressor failing when compressing non-JS script tags

The HTML compressor tries to compress inline script tags regardless of whether it's Javascript or not, for example:

<script type="text/x-handlebars-template" data-tmpl-name="category" id="tmplCategory">
<section class="category">
  <header>
    <h3>{{name}}</h3>

    <p>{{desc}}</p>
  </header>
  <div>{{&emotes}}</div>
</section>
</script>

Parsing the <script> tag to read the type attribute and skipping if it's not a known Javascript type would fix this

Error during optimizing images

Homebrew + Mac OS X 10.7 and I got errors while image optimization is proceeding:

-imagespng:
     [echo] Optimizing images...
     [echo] This part might take a while. But everything else is already done.
     [echo]  
     [echo] First, we run optipng on the .png files...
    [apply] ** Error: The option -out requires one input file
    [apply] Result: 1
    ....

Is this a bug?

Discussion: Remove manifest.appcache task?

See discussion on the parent project :

h5bp/html5-boilerplate#1060

The comment is removed.

The question is... is the simple task we have here doing more harm than good? Do we leave it and just let people use it caveat emptor?

I'm leaning towards killing it because it doesn't encompass the nuance needed to leverage offline properly. Most of the rest of what we do here ends up with a best practice outcome. That is not necessarily the case with this task.

createproject script breaks

i'm using git bash on a vista machine
when i run createproject.sh from bash, it breaks after asking for the new project's name.
in the file, line 70, i see: cd -- "$src", which is basically asking to change dir to the same dir
the script works when i replace it with simply: cd .. i.e. move a level up

$ ./createproject.sh
To create a new html5-boilerplate project, enter a new directory name:
newproject
Created Directory: c:/root/3rdparty/h5bp-html5-boilerplate-112bad9/build/../newproject
cp: cannot stat css': No such file or directory cp: cannot statjs': No such file or directory
cp: cannot stat img': No such file or directory cp: cannot statbuild': No such file or directory
cp: cannot stat *.html': No such file or directory build.xml' -> c:/root/3rdparty/h5bp-html5-boilerplate-112bad9/build/../newproject/build.xml' project.xml' -> c:/root/3rdparty/h5bp-html5-boilerplate-112bad9/build/../newproject/project.xml' cp: cannot stat_.txt': No such file or directory
cp: cannot stat _.png': No such file or directory cp: cannot stat *.ico': No such file or directory
cp: cannot stat`.htaccess': No such file or directory
Created Project: c:/root/3rdparty/h5bp-html5-boilerplate-112bad9/build/../newproject

Handle OptiPNG version and metadata stripping on Mac/Linux

As surfaced by #39 there are some issues with optipng versions and stripping metadata. We need to be able to see if the right version of otipng is installed and then strip/not strip metadata accordingly. this works on windows since we just ship the latest version.

Basically we need to be more awesome.

Config properties load order

Properties files are currently loaded in this order

<!-- load property files -->
<property file="build/config/project.properties"/>
<property file="build/config/default.properties"/>

I think this is not correct, since the build script should load the default first and then the custom project properties (perhaps containing the properties to override).

Am I wrong?

Cheers,
Fabrizio

runnable build script from outside the build/ dir

from: h5bp/html5-boilerplate#867

runnable build script from outside the build/ dir

It would probably be better to open another issue, but I'm doing it right here since I see it kinda related.

It would be cool to be able to run the build script from anywhere on the system. I'm not sure how it could be applied to the ant script but I'm thinking basically about some kind of executable wrapper around the build scripts (like an h5bp-build command).

The idea is to make it easier to run the build script on a variety of folder structure, and not necessarely from within an h5bp clone or download.

The scripts should know from where the command is run, and adjust relative paths accordingly. Doing so, it may provide a greater level of flexibility (combined with prompts, or local configuration).

The command may even include some scaffolding helper, by using the createproject.sh script.

Which Java JDK should Windows users install?

According to the Build Script page, http://www.oracle.com/technetwork/java/javase/downloads/index.html, it says that Windows users should download Java JDK because JRE isn't enough (but doesn't cite why or any follow-up information).

I had JRE installed already and tried to run the latest build of the build script but had a few problems. When I initially ran the build script (in h5bp/build folder), most everything ran correctly but the very first error I received said it was looking for tools.jar.

It was then that I picked willy nilly the first link of the four on the page to install the JDK. Was that the right one? I assumed it would fix the problem, but it didn't Even after installing the JDK it will gave me an error that this specific tools.jar file was missing. So I just copied and pasted that file from the JDK into the JRE location it was looking for it. I noticed absolutely no different in the way Ant Build ran.

So which JDK should Windows users install? Why isn't the JRE good enough? Can I just find some random tools.jar and past it into a JRE installation? If someone provides an answer here, I'd be glad to put it into the wiki.

Create Alternative Concat Task

#57 and #55 have surfaced issues with the new, smarter concat method.

Solution:

1 Set a flag in the properties files for concat preference. It will default to the smart one.
2 create an importable task to overwrite tasks as needed
3. import and cheer.

I'm going to complete opposite direction and just leveraging a <filelist.> If the smart task doesn't work and a <filelist> is too hard to deal with, I don't know that we're going to be able to come up with a generic solution to your build issues.

QUnit Tests

Hi,

How do I configure the HTML5BP Ant build script to execute my QUnit tests?

Thanks,
Cas

Extending the build script functionality

Ported from h5bp/html5-boilerplate#831
Originally opened by @necolas

Just sharing an idea about how the build script might be adapted to move some of the configuration into the HTML, and maybe make it more flexible and accessible to front-enders at the same time. It might be a bit ridiculous but here goes...

Pretty much every build script I've had to work with involved listing the files to be minified/concatenated in groups in a configuration file, sometimes that name and location of the output file was included there too. Then a line of server-side code is placed in the template to mark where the generated file should be output in the HTML source in the production environment.

The JS concatenation stuff is sort of like that but hard-coded and limited. Maybe we could expand upon it and make the comments more obviously related to the build script and exist in discrete blocks. An idea I discussed with @mklabs was to have some sort of "build script tag" in the HTML comment. For example:

<!-- [[ build css site.css ]] -->
    ...stylesheets...
<!-- [[ endbuild ]] -->

<!-- [[ build js head-scripts.js ]] -->
    ...scripts that need to be in the head...
<!-- [[ endbuild ]] -->



<!-- [[ build js libs.js ]] -->
    ...libraries...
<!-- [[ endbuild ]] -->

<!-- [[ build js site.js ]] -->
    ...all your jquery plugins...
    ...developer authored scripts...
<!-- [[ endbuild ]] -->

Everything inside a "build block" would be minified, concatenated, and revved into the '[md5].site.css' filename based on the one that is specified in the comment. You could use whatever name you want. And anything @import-ed inside those stylesheets would be included too.

The 'css' part would be a label to attach specific customisations made from within the config file like the compression library used and the output directory. So 'css' might specify to use YUI's compressor and output to /publish/css/site.css. You might just have 1 for CSS and 1 for JS, or maintain several different patterns.

Not sure how things would be handled if your moved the files around relative to each other (e.g. the image paths in the CSS), or how the check would work to make sure you weren't rebuilding unchanged files.

Anyway, that's it.

js dir and concat explanation

Hi,

Since hbp5 v3, I really don't understand js min&concat.

Before, I put extra libs, like colorbox, in mylibs.
My pages are in php, index.php only contains security filters and others constant definition. All work is done under /includes dir.
My controller is common.inc.php.

I used to add this in project.properties :
file.pages = */.php, */${dir.includes}/.php

Now, It doesn't work : files are not concatened nor just included.

Only this works :
file.root.page = includes/common.inc.php
but with a lot of java errors (like C:\www\test_site\intermediate\java.lang.NullPointerException does not exist).

file.pages.default.include instead of file.root.page doesn't work.

So, what's the right way to min&concat files between ?

And is it possible to have distinct "groups". For example, in my common.inc.php :

/ edit : wow ! all tags are filtered ! Not very easy to describe... /

[head]
some scripts (script1+script2+script3) included under condition (page name for example)
[/head]
[body]
scripts between (myscript+plugins+main)
[/body]

I would like to have a common script (myscript+plugins+main) and a specific (script1+script2+script3).

Thanks.

How to bypass compress/concat for .js files in mylibs

I can't get the script to bypass js files in a subdirectory of mylibs. I have t/he bootstrap .js linked and working fine for development in a /js/mylibs/boostrap/ directory. I want to exclude some of them from the build routine. Per instructions, I uncomment the bypass rule in project.properties and add:

file.js.bypass = bootstrap/bootstrap-carousel.js

I expected an unminified version of the file to be copied to /publish/js/mylibs/bootstrap/bootstrap-carousel.js . Links from html files are correctly changed to point to this file, but it doesn't exist.

I understand that another way to opt out of compression/concatenation is to link outside the <!-- scripts concatenated and minified via build script --> comment block. This doesn't work for me either.

Any advice on how to use either of these two methods (or combine them?). I don't assume it's a problem with the script, but the doc isn't clear to me.

Have build script automatically rev image filenames

Ported from h5bp/html5-boilerplate#774
Originally opened by @necolas

We've got the far futures Expires header for caching static resources, and the build script automatically revs the CSS and JS when there is a change to the contents, but if you change an image you still have to manually rev the filename. This is true for images embedded in the HTML or referenced in the CSS.

It would be great if the build script (if not Ant, then then upcoming Rake or Cake versions) could somehow handle the automatic revving of image filenames if they have been updated. This was first mentioned in passing in h5bp/html5-boilerplate#707

main.js not incuded in concatenated js file

Firstly, there's a strong chance that this issue may be due to user error, so any advice would be welcomed!

I've been using h5bp for around a year, but this is the first occasion I've used the latest version. I'm also using h5bp within a WordPress theme, however (and I may be incorrect here), the guide refers to modifying build.xml - this doesn't appear to be necessary anymore with the latest version as my css and js are being replaced with the hash file location correctly.

My problem is that the concatenated js file isn't including main.js.

My script tags are as standard:

  <!-- scripts concatenated and minified via build script -->
  <script src="<?php bloginfo('template_directory')?>/js/main.js"></script>
  <script src="<?php bloginfo('template_directory')?>/js/plugins.js"></script>

  <!-- end scripts -->

After running ant build the intermediate folder contains both main.js and plugins.js (along with scripts-concat.min.js) - note scripts-concat.min.js does not contain my main.js code.

Within the publish folder, the js folder contains the concatenated js file (eg c3cd3d9.js) my footer.php file is also updated to reference this file:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="<?php bloginfo('template_directory')?>/js/vendor/jquery-1.7.1.min.js"><\/script>')</script>
<script src="<?php bloginfo('template_directory')?>/js/vendor/prettyPhoto.js"></script>

<script src='<?php bloginfo('template_directory')?>/js/348ac91.js'></script>

I've attempted to ascertain whether this was due to one of my jQuery helper files (included in plugins.js) - I've removed all code from plugins.js and this still results in main.js not being included within the concatenated file (i.e. the concat file is now empty too)

I then looked into whether the contents of main.js could be causing an issue - I replaced all of my code with

$(document).ready(function() {
    console.log('jQuery ready');

});

This too results in only plugins.js being included within the concatenated js file.

Finally, to temporarily overcome my issue I manually inserted my original main.js code beneath my helper code within plugins.js. As expected this ensures my code is included in the concatenated file.

Has anyone experienced a similar issue and / or able to offer any assistance?

Cheers

Martin

HTML validation

If build script support jslint and csslint, wouldn't be great if was some html validation tool. I didn't found any console tool, but maybe someone know.

Include pngquant in image optimization process

A site I'm currently working on makes very heavy use of transparent PNGs, and I've found that by running pngquant on the entire project I can get tremendous savings in file size.

I'm sure you see where I'm going with this. I'd love to have the build script do this for me. It seems like it would be pretty simple, and I've already taken an unsuccessful stab at it:

<echo message="Now, we run pngquant on the .png files for much smaller files..."/>

<apply executable="${basedir}/${dir.build.tools}/pngquant.exe" dest="./${dir.publish}/${dir.images}/" osfamily="unix">
    <fileset dir="./${dir.source}/${dir.images}/" includes="**/*.png"  excludes="${images.bypass}, ${images.default.bypass}"/>
    <arg value="-ext .png -force"/>
    <arg value="256"/>
    <targetfile/>
    <srcfile/>
    <mapper type="identity"/>
</apply>

-ext .png -force forces a replace of the existing files, and 256 sets the amount of colors to use. These are the only args I've ever needed for pngquant.

The "pngquant.exe" is in the place it should be. In fact, the build script is finding it and displaying the "help" for it, but then the script just hangs which makes me think my settings somewhere else are incorrect. I know nothing about working with Ant, and the documentation is pretty intimidating (the Ant documentation, not the HTML5BP docs, which are great).

Anybody have any ideas?

Deploying publish folder with Capistrano?

What are your thoughts on being able to deploy the publish folder to production using Capistrano?
Capistrano works by pulling the project down from a repo and deploying it server side.
Now at the moment, it doesn't seem logical to have the publish folder in a git repo along with the development code, so would there be a way to build the project server side, clean up all the folders and move the contents of publish to the web root?

Automated deployment for html and php projects would be so appealing when partnered with the build script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.