Stackedit/tools/run_optimize

30 lines
831 B
Plaintext
Raw Normal View History

2013-05-18 14:52:20 +00:00
#!/bin/sh
2013-08-23 23:50:14 +00:00
echo
2013-08-26 11:32:20 +00:00
2013-08-23 23:50:14 +00:00
echo '### Installing dependencies ###'
2013-05-18 14:52:20 +00:00
npm install requirejs
2013-08-23 23:50:14 +00:00
npm install less
export PATH=${PATH}:`pwd`/node_modules/requirejs/bin/:`pwd`/node_modules/less/bin/
echo
2013-08-26 11:32:20 +00:00
2013-08-23 23:50:14 +00:00
echo '### Optimizing JavaScript ###'
2013-08-26 11:32:20 +00:00
rm -rf res-min
2013-07-07 20:23:00 +00:00
r.js -o tools/optimize-js.json
2013-08-23 23:50:14 +00:00
echo
2013-08-26 11:32:20 +00:00
2013-08-23 23:50:14 +00:00
echo '### Optimizing CSS ###'
2013-08-26 11:32:20 +00:00
mkdir -p res-min/themes
cd res/themes
for theme in *; do lessc $theme | sed 's/@import/@import (less)/g' | lessc -x - > `echo ../../res-min/themes/${theme} | sed 's/.less$/.css/'`; done
2013-08-23 23:50:14 +00:00
cd ../..
2013-08-26 11:32:20 +00:00
cp -R res/libs/fontello/font res-min/
cp -R res/img res-min/
2013-08-23 23:50:14 +00:00
echo
2013-08-26 11:32:20 +00:00
2013-08-23 23:50:14 +00:00
echo '### Updating cache.manifest ###'
sed -n '1,/#dynamic/p' cache.manifest > cache.manifest.new
printf "\n# `date`\n" >> cache.manifest.new
2013-08-26 11:32:20 +00:00
find res-min -type f >> cache.manifest.new
2013-08-23 23:50:14 +00:00
printf "\nNETWORK:\n*" >> cache.manifest.new
mv cache.manifest.new cache.manifest