#!/bin/sh

echo ""
echo "  DataTables build"
echo ""

cd ../media/src

cp DataTables.js DataTables.js.build

IFS='%'

echo "  Importing files:"
grep "require(" DataTables.js.build > /dev/null
while [ $? -eq 0 ]; do
	REQUIRE=$(grep "require(" DataTables.js.build | head -n 1)

	SPACER=$(echo ${REQUIRE} | cut -d r -f 1)
	FILE=$(echo ${REQUIRE} | sed -e "s#^.*require('##g" -e "s#');##")
	DIR=$(echo ${FILE} | cut -d \. -f 1)

	echo "    $FILE"

	sed "s#^#${SPACER}#" < ${DIR}/${FILE} > ${DIR}/${FILE}.build

	sed -e "/${REQUIRE}/r ${DIR}/${FILE}.build" -e "/${REQUIRE}/d" < DataTables.js.build > DataTables.js.out
	mv DataTables.js.out DataTables.js.build

	rm ${DIR}/${FILE}.build

	grep "require(" DataTables.js.build > /dev/null
done

mv DataTables.js.build ../js/jquery.dataTables.js

#!/bin/sh

# DEFAULTS
CLOSURE="/usr/local/closure_compiler/compiler.jar"
JSDOC3="/usr/local/jsdoc3/jsdoc.jar"


echo ""
echo "  DataTables build"
echo ""

cd ../media/src

cp DataTables.js DataTables.js.build

IFS='%'

echo "  Importing files:"
grep "require(" DataTables.js.build > /dev/null
while [ $? -eq 0 ]; do
	REQUIRE=$(grep "require(" DataTables.js.build | head -n 1)

	SPACER=$(echo ${REQUIRE} | cut -d r -f 1)
	FILE=$(echo ${REQUIRE} | sed -e "s#^.*require('##g" -e "s#');##")
	DIR=$(echo ${FILE} | cut -d \. -f 1)

	echo "    $FILE"

	sed "s#^#${SPACER}#" < ${DIR}/${FILE} > ${DIR}/${FILE}.build

	sed -e "/${REQUIRE}/r ${DIR}/${FILE}.build" -e "/${REQUIRE}/d" < DataTables.js.build > DataTables.js.out
	mv DataTables.js.out DataTables.js.build

	rm ${DIR}/${FILE}.build

	grep "require(" DataTables.js.build > /dev/null
done

mv DataTables.js.build ../js/jquery.dataTables.js


if [ "$1" = "compress" ]; then
	java -jar $CLOSURE --js ../js/jquery.dataTables.js > ../js/jquery.dataTables.min.closure.js
fi
Add a 'compress' "target" to the build script (still needs a bit of tidy up). Going to continue using Closure Compiler for DataTables. Tried UglifyJS as well, but found that added about 11K to the size of the library when compressed, relative to Closure:
Add a 'compress' "target" to the build script (still needs a bit of tidy up). Going to continue using Closure Compiler for DataTables. Tried UglifyJS as well, but found that added about 11K to the size of the library when compressed, relative to Closure:

$ ls -l ../media/js
total 1272
-rw-r--r--  1 allan  wheel  316031  6 Dec 16:51 jquery.dataTables.js
-rw-r--r--  1 allan  wheel   70608  6 Dec 16:51 jquery.dataTables.min.closure.js
-rw-r--r--  1 allan  wheel   81643  6 Dec 16:51 jquery.dataTables.min.uglify.js
-rw-r--r--  1 allan  wheel   93867  3 Dec 17:49 jquery.js
