From 71f5781c86224652729d8b1fc1de820a430ba08b Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Sat, 28 Mar 2015 23:52:16 +0700 Subject: [PATCH] Update build script and nginx config --- .gitignore | 3 ++- Makefile | 26 +++++++------------------- app/{index.html => app.html} | 0 build/app.html | 11 +++++++++++ nginx.conf | 14 ++++++++------ 5 files changed, 28 insertions(+), 26 deletions(-) rename app/{index.html => app.html} (100%) create mode 100644 build/app.html diff --git a/.gitignore b/.gitignore index dc7611d..fd5866f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ // Compiled /app/jsx/build -/build +/build/app.css +/build/app.js diff --git a/Makefile b/Makefile index 28a259c..842e54a 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,12 @@ JSX = ./node_modules/react-tools/bin/jsx -UGLIFY = ./node_modules/uglify-js/bin/uglifyjs -CLEANCSS = ./node_modules/clean-css/bin/cleancss +JSMIN = ./node_modules/uglify-js/bin/uglifyjs +CSSMIN = ./node_modules/clean-css/bin/cleancss cloc: cloc . --exclude-dir=node_modules,app/bower_components,app/jsx/build/.module_cache dist: # Compiling JSX - mkdir -p build rm -rf app/jsx/build $(JSX) --extension jsx app/jsx app/jsx/build @@ -20,7 +19,7 @@ dist: # Prepending dependencies to the list # Concatenation # Minification - cat app/index.html \ + cat app/app.html \ | grep script \ | grep -v bower \ | cut -d '"' -f 2 \ @@ -30,7 +29,7 @@ dist: echo app/bower_components/lodash/lodash.min.js && \ cat ) \ | xargs cat \ - | $(UGLIFY) > build/app.js + | $(JSMIN) > build/app.js # Compressing CSS # @@ -40,22 +39,11 @@ dist: # Adding "app" prefix # Concatenation # Minification - cat app/index.html \ + cat app/app.html \ | grep stylesheet \ + | grep -v fonts.googleapis.com \ | grep -v opensans \ | 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 \ - \n /g' \ - | perl -pe 's/\n/SCRIPT_TAG/g' \ - | perl -pe 's/(SCRIPT_TAG\s*)+/\ - + diff --git a/nginx.conf b/nginx.conf index fcb7632..f6836fb 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,16 +1,16 @@ upstream empact { - server 127.0.0.1:8080 max_fails=3 fail_timeout=30s; + server 127.0.0.1:8080 weight=10; + # Server with enabled profiling + # server 127.0.0.1:8081 max_fails=1 fail_timeout=30s; } server { listen 80 default_server; - root /home/empact/app/static; + root /home/www/app/static; charset utf-8; - location / { - index hello.html; - } location ~ ^/app/ { + add_header Cache-Control private; add_header X-UA-Compatible IE=edge; add_header Content-Language en; rewrite ^/app/(.*) /app.html last; @@ -21,7 +21,9 @@ server { } location /favicon.ico { - alias /home/empact/app/static/images/favicon.ico; + alias /home/www/app/static/images/favicon.ico; + add_header Cache-Control public; + expires 1d; } location ~ .*\.(js|css|png)$ { add_header Cache-Control public;