Skip to content

Commit

Permalink
build script: manifest improvements (and others).. details:
Browse files Browse the repository at this point in the history
manifest:
* use a manifest template from build/config/cache.appcache each time
* the only css we are dropping in is the style.css (SHA'd), no more
* we include all js/mylibs/bypass files and all js/libs/*.min.js files
* change default name of manifest to `cache.appcache` but im gonna change it to `manifest.appcache` next commit ;)
* state of repo temporarily includes a manifest but that will revert soon

other:
* rename libs-concat.js to mylibs-concat.js for logic's sake
* add @defer attribute to concated script
  • Loading branch information
paulirish committed Aug 10, 2011
1 parent 00be05a commit f10f81a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 53 deletions.
43 changes: 15 additions & 28 deletions build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@

<echo message="Concatenating JS libraries"/>
<!-- overwrite=no here means not to overwrite if the target is newer than the sources -->
<concat destfile="./${dir.intermediate}/${dir.js}/libs-concat.js" overwrite="no">
<concat destfile="./${dir.intermediate}/${dir.js}/mylibs-concat.js" overwrite="no">
<fileset dir="./${dir.intermediate}/${dir.js.mylibs}/"
includes="**/*.js"
excludes="${file.js.bypass}"/>
Expand All @@ -512,7 +512,7 @@
<!-- overwrite=no here means not to overwrite if the target is newer than the sources -->
<concat destfile="./${dir.intermediate}/${dir.js}/scripts-concat.min.js" overwrite="no">
<fileset dir="./${dir.intermediate}/${dir.js}/">
<include name="libs-concat.js"/>
<include name="mylibs-concat.js"/>
<include name="scripts-concat.js"/>
</fileset>
</concat>
Expand Down Expand Up @@ -558,7 +558,7 @@
<include name="${dir.js}/**/*.js"/>
<exclude name="${dir.js.mylibs}/**/*.js"/>
<exclude name="${dir.js}/scripts-concat.js"/>
<exclude name="${dir.js}/libs-concat.js"/>
<exclude name="${dir.js}/mylibs-concat.js"/>
<exclude name="${dir.js}/scripts-concat.min.js"/>
<exclude name="${dir.js}/plugins.js"/>
<exclude name="${dir.js}/script.js"/>
Expand Down Expand Up @@ -618,7 +618,7 @@

<echo message="Update the HTML to reference our concatenated script file: ${scripts.js}"/>
<!-- style.css replacement handled as a replacetoken above -->
<replaceregexp match="&lt;!-- scripts concatenated [\d\w\s\W]*?!-- end ((scripts)|(concatenated and minified scripts))--&gt;" replace="&lt;script src='${scripts.js}\'&gt;&lt;/script&gt;" flags="m">
<replaceregexp match="&lt;!-- scripts concatenated [\d\w\s\W]*?!-- end ((scripts)|(concatenated and minified scripts))--&gt;" replace="&lt;script defer src='${scripts.js}\'&gt;&lt;/script&gt;" flags="m">
<fileset dir="${dir.intermediate}" includes="${page-files}"/>
</replaceregexp>
<!--[! use comments like this one to avoid having them get minified -->
Expand All @@ -633,52 +633,39 @@
<if>
<equals arg1="${clean-manifest}" arg2="true" />
<then>
<echo message="copying ${manifest} to /${dir.intermediate}"/>
<copy file="${dir.source}/${manifest}" tofile="${dir.intermediate}/${manifest}" />
<echo message="copying a fresh ${dir.build}/config/${manifest} to /${dir.intermediate}"/>

<delete file="${dir.intermediate}/${manifest}"/>
<copy file="${dir.build}/config/${manifest}" tofile="${dir.intermediate}/${manifest}" />

<echo message="manifest cleaning" />

<!-- update version -->
<echo message="Updating the site.manifest version date to today"/>
<echo message="Updating the site.manifest version date to today, current time"/>
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss"/>
</tstamp>
<replaceregexp match="# version .+" replace="# version ${TODAY}" file="${dir.intermediate}/${manifest}"/>

<!-- replace stylesheet files -->
<echo message="Updating the site.manifest with the new css filename: ${style.css}"/>
<for param="file">
<path>
<fileset dir="./${dir.intermediate}/${dir.css}/"
includes="**/*.css"
excludes="${file.css.bypass}"/>
</path>
<sequential>
<basename property="filename.@{file}" file="@{file}" />
<!-- <echo message="replacing ${filename.@{file}}"/> -->
<replaceregexp match=".+${filename.@{file}}" replace="" file="${dir.intermediate}/${manifest}" />
</sequential>
</for>
<replace token="# css files" value="# css files${line.separator}/${style.css}" file="${dir.intermediate}/${manifest}" />
<replace token="# css files" value="# css files${line.separator}${style.css}" file="${dir.intermediate}/${manifest}" />

<!-- replace javascript files -->
<echo message="Updating the site.manifest with the new js filename: ${scripts.js}"/>
<for param="file">
<path>
<fileset dir="./${dir.intermediate}/${dir.js}/"
includes="*.js"
excludes="${file.js.bypass}"/>
<fileset dir="./${dir.intermediate}/${dir.js.mylibs}/"
includes="**/*.js"
excludes="${file.js.bypass}"/>
includes="${file.js.bypass}" />
<fileset dir="./${dir.intermediate}/${dir.js.libs}/"
includes="*.min.js"/>
</path>
<sequential>
<basename property="filename.@{file}" file="@{file}" />
<!-- <echo message="replacing ${filename.@{file}}"/> -->
<replaceregexp match=".+${filename.@{file}}" replace="" file="${dir.intermediate}/${manifest}" />
<replaceregexp match="# js files" replace="# js files${line.separator}${filename.@{file}}" file="${dir.intermediate}/${manifest}" />
</sequential>
</for>
<replace token="# js files" value="# js files${line.separator}/${scripts.js}" file="${dir.intermediate}/${manifest}" />
<replace token="# js files" value="# js files${line.separator}${scripts.js}" file="${dir.intermediate}/${manifest}" />

<echo message="copying ${manifest} to /${dir.publish}"/>
<copy file="${dir.intermediate}/${manifest}" tofile="${dir.publish}/${manifest}" />
Expand Down
20 changes: 20 additions & 0 deletions build/config/cache.appcache
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CACHE MANIFEST

# version xxxxxxxxx

CACHE:
# html files
index.html

# css files



# js files



FALLBACK:

NETWORK:
*
7 changes: 3 additions & 4 deletions build/config/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ file.pages =
# site manifest
# this is the name of the manifest file you declared in the <html> tag
# Example:
# file.manifest = site.manifest
file.manifest =
file.manifest = cache.appcache

# Excluded files and dirs
#
Expand All @@ -43,11 +42,11 @@ file.exclude =
#
# Add any files or folders within the mylibs directory that you want to be copied to the publish directory as a
# comma separated list
# These files will not be concatinated or minimized and will simply be copied over as is.
# These files will not be concatenated or minimized and will simply be copied over as is.
# Note: you cannot declare an empty file.bypass property, it would exclude the entire mylibs folder
# Example:
# file.js.bypass = widgets.js, gadgets.js, gidgets.js
# file.js.bypass
# file.js.bypass =


# Specify an environment to build
Expand Down
1 change: 0 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; }
audio:not([controls]) { display: none; }
[hidden] { display: none; }


/* =============================================================================
Base
========================================================================== */
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!-- add manifest="site.manifest" if needed -->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" manifest="cache.appcache"> <!--<![endif]-->
<head>
<meta charset="utf-8">

Expand Down
19 changes: 0 additions & 19 deletions site.manifest

This file was deleted.

0 comments on commit f10f81a

Please sign in to comment.