diff --git a/Makefile b/Makefile index 1f00418..022207c 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,43 @@ +JSX = ./node_modules/react-tools/bin/jsx UGLIFY = ./node_modules/uglify-js/bin/uglifyjs CLEANCSS = ./node_modules/clean-css/bin/cleancss cloc: cloc . --exclude-dir=app/bower_components,app/scripts/.module-cache -static: - $(UGLIFY) \ - app/bower_components/react/react.min.js \ - app/bower_components/react-router/build/global/ReactRouter.min.js \ - app/bower_components/lodash/lodash.min.js \ - app/js/* \ - app/jsx/build/charts/* \ - app/jsx/build/app.js \ - > build/app.js - cat \ - app/bower_components/normalize.css/normalize.css \ - app/css/* \ +dist: + # Compiling JSX + mkdir -p build + rm -rf app/jsx/build + $(JSX) --extension jsx app/jsx app/jsx/build + + # Compressing JS + cat app/index.html \ + | 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 + + # Compressing CSS + cat app/index.html \ + | grep stylesheet \ + | grep -v http \ + | cut -d '"' -f 4 \ + | sed -e 's/^/app/' \ + | xargs cat \ | $(CLEANCSS) -o build/app.css + + # Replacing all link tags with a single one + # Replacing all script tags with a single one + cat app/index.html \ + | perl -pe 's/\n/STYLE_TAG/g' \ + | perl -pe 's/(STYLE_TAG\s*)+/\n /g' \ + | perl -pe 's/\n/SCRIPT_TAG/g' \ + | perl -pe 's/(SCRIPT_TAG\s*)+/ diff --git a/build/index.html b/build/index.html index ea5dd48..6391b8a 100644 --- a/build/index.html +++ b/build/index.html @@ -3,14 +3,8 @@ Empact - - - - - - - + diff --git a/package.json b/package.json index bd494a2..a78dc71 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "empact", "private": true, "dependencies": { + "react-tools": "0.12.2", "uglify-js": "2.4.17", "clean-css": "3.1.7" }