1
0
Fork 0
empact/Makefile

62 lines
1.7 KiB
Makefile
Raw Normal View History

2015-03-18 16:23:43 +00:00
JSX = ./node_modules/react-tools/bin/jsx
2015-03-17 08:57:45 +00:00
UGLIFY = ./node_modules/uglify-js/bin/uglifyjs
CLEANCSS = ./node_modules/clean-css/bin/cleancss
2015-03-08 15:19:28 +00:00
cloc:
2015-03-18 16:23:48 +00:00
cloc . --exclude-dir=node_modules,app/bower_components,app/jsx/build/.module_cache
2015-03-17 08:57:45 +00:00
2015-03-18 16:23:43 +00:00
dist:
# Compiling JSX
mkdir -p build
rm -rf app/jsx/build
$(JSX) --extension jsx app/jsx app/jsx/build
# Compressing JS
2015-03-19 13:55:39 +00:00
#
# Get all script tags
# Ignore Bower deps, include minified versions later
# Splitting string by " and taking second field (URI)
# Adding "app" prefix
# Prepending dependencies to the list
# Concatenation
# Minification
2015-03-18 16:23:43 +00:00
cat app/index.html \
2015-03-19 13:55:39 +00:00
| grep script \
| grep -v bower \
| cut -d '"' -f 2 \
| sed -e 's/^/app/' \
| ( echo app/bower_components/react/react.min.js && \
echo app/bower_components/react-router/build/global/ReactRouter.min.js && \
echo app/bower_components/lodash/lodash.min.js && \
cat ) \
| xargs cat \
| $(UGLIFY) > build/app.js
2015-03-18 16:23:43 +00:00
# Compressing CSS
2015-03-19 13:55:39 +00:00
#
# Get all style tags
# Ignore local Open Sans stylesheet
# Splitting string by " and taking fourth field (URI)
# Adding "app" prefix
# Concatenation
# Minification
2015-03-18 16:23:43 +00:00
cat app/index.html \
2015-03-19 13:55:39 +00:00
| grep stylesheet \
| grep -v opensans \
| cut -d '"' -f 4 \
| sed -e 's/^/app/' \
| xargs cat \
| $(CLEANCSS) -o build/app.css
2015-03-18 16:23:43 +00:00
# Replacing all link tags with a single one
# Replacing all script tags with a single one
cat app/index.html \
2015-03-19 13:55:39 +00:00
| perl -pe 's/<link.*>\n/STYLE_TAG/g' \
| perl -pe 's/(STYLE_TAG\s*)+/\
<link rel="stylesheet" href="\/app.css">\n \
<link rel="stylesheet" href="\/\/fonts.googleapis.com\/css?family=Open\+Sans:400,300,600">\n /g' \
| perl -pe 's/<script.*>\n/SCRIPT_TAG/g' \
| perl -pe 's/(SCRIPT_TAG\s*)+/\
<script type="text\/javascript" src="\/app.js"><\/script>\n/g' \
> build/index.html