mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Build: ant size
will now give you a report detailing differences in size since the last time you ran the report
This commit is contained in:
parent
bdd602e21b
commit
264139b225
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,6 @@
|
||||
build/dist
|
||||
build/size
|
||||
build/build/.sizecache.json
|
||||
docs
|
||||
.project
|
||||
*~
|
||||
|
@ -32,6 +32,7 @@
|
||||
<property name="docs.dir" value="${dist.dir}/docs/" />
|
||||
|
||||
<property name="min.dir" value="${dist.dir}/ui/minified" />
|
||||
<property name="size.dir" value="size" />
|
||||
|
||||
<property name="concatenated" value="jquery-ui" />
|
||||
<property name="concatenated.i18n" value="jquery-ui-i18n" />
|
||||
@ -357,6 +358,37 @@
|
||||
<echo message="All trailing spaces removed." />
|
||||
</target>
|
||||
|
||||
<target name="size" depends="copy, minify, replace-version, prepend-header" description="Report sizes of files">
|
||||
<echo message="Collecting files to size" />
|
||||
<mkdir dir="${size.dir}" />
|
||||
<copy todir="${size.dir}">
|
||||
<fileset dir="${dist.dir}/ui" includes="*.js" />
|
||||
<fileset dir="${dist.dir}/ui/i18n" includes="*.js" />
|
||||
<fileset dir="${dist.dir}/ui/minified" includes="*.js" />
|
||||
<fileset dir="${dist.dir}/ui/minified/i18n" includes="*.js" />
|
||||
<fileset dir="${dist.dir}/themes/base" includes="*.css" />
|
||||
<fileset dir="${dist.dir}/themes/base/minified" includes="*.css" />
|
||||
</copy>
|
||||
<echo message="GZipping Minified" />
|
||||
<parallel threadsperprocessor="2">
|
||||
<apply executable="gzip">
|
||||
<fileset dir="${size.dir}" includes="*.min.js" />
|
||||
<fileset dir="${size.dir}" includes="*.min.css" />
|
||||
<arg value="-c" />
|
||||
<srcfile />
|
||||
<redirector>
|
||||
<outputmapper id="out" type="glob" from="*" to="${size.dir}/*.gz"/>
|
||||
</redirector>
|
||||
</apply>
|
||||
</parallel>
|
||||
<echo message="Comparing file size with previous build" />
|
||||
<exec executable="bash">
|
||||
<arg value="-c" />
|
||||
<arg value="wc -c ${size.dir}/* | `which node nodejs` build/sizer.js" />
|
||||
</exec>
|
||||
<delete dir="${size.dir}" />
|
||||
</target>
|
||||
|
||||
<target name="cdn">
|
||||
<delete dir="${cdndist.dir}" />
|
||||
<mkdir dir="${cdndist.dir}" />
|
||||
|
35
build/build/sizer.js
Normal file
35
build/build/sizer.js
Normal file
@ -0,0 +1,35 @@
|
||||
var fs = require( "fs" ),
|
||||
stdin = process.openStdin(),
|
||||
rsize = /(\d+).*?(jquery\S+)/g,
|
||||
oldsizes = {},
|
||||
sizes = {};
|
||||
|
||||
try {
|
||||
oldsizes = JSON.parse( fs.readFileSync( __dirname + "/.sizecache.json", "utf8" ) );
|
||||
} catch(e) {
|
||||
oldsizes = {};
|
||||
};
|
||||
|
||||
stdin.on( "data" , function( chunk ) {
|
||||
var match;
|
||||
|
||||
while ( match = rsize.exec( chunk ) ) {
|
||||
sizes[ match[2] ] = parseInt( match[1], 10 );
|
||||
}
|
||||
});
|
||||
|
||||
function lpad( str, len, chr ) {
|
||||
return ( Array(len+1).join( chr || " ") + str ).substr( -len );
|
||||
}
|
||||
|
||||
stdin.on( "end", function() {
|
||||
fs.writeFileSync( __dirname + "/.sizecache.json", JSON.stringify( sizes, true ), "utf8" );
|
||||
for ( var key in sizes ) {
|
||||
var diff = oldsizes[ key ] && ( sizes[ key ] - oldsizes[ key ] );
|
||||
if ( diff > 0 ) {
|
||||
diff = "+" + diff;
|
||||
}
|
||||
console.log( "%s %s %s", lpad( sizes[ key ], 8 ), lpad( diff ? "(" + diff + ")" : "(-)", 8 ), key );
|
||||
}
|
||||
process.exit();
|
||||
});
|
Loading…
Reference in New Issue
Block a user