1
0
Fork 0

Update build script and nginx config

This commit is contained in:
Gregory Eremin 2015-03-28 23:52:16 +07:00
parent 86fbe67ec9
commit 71f5781c86
5 changed files with 28 additions and 26 deletions

3
.gitignore vendored
View File

@ -11,4 +11,5 @@
// Compiled // Compiled
/app/jsx/build /app/jsx/build
/build /build/app.css
/build/app.js

View File

@ -1,13 +1,12 @@
JSX = ./node_modules/react-tools/bin/jsx JSX = ./node_modules/react-tools/bin/jsx
UGLIFY = ./node_modules/uglify-js/bin/uglifyjs JSMIN = ./node_modules/uglify-js/bin/uglifyjs
CLEANCSS = ./node_modules/clean-css/bin/cleancss CSSMIN = ./node_modules/clean-css/bin/cleancss
cloc: cloc:
cloc . --exclude-dir=node_modules,app/bower_components,app/jsx/build/.module_cache cloc . --exclude-dir=node_modules,app/bower_components,app/jsx/build/.module_cache
dist: dist:
# Compiling JSX # Compiling JSX
mkdir -p build
rm -rf app/jsx/build rm -rf app/jsx/build
$(JSX) --extension jsx app/jsx app/jsx/build $(JSX) --extension jsx app/jsx app/jsx/build
@ -20,7 +19,7 @@ dist:
# Prepending dependencies to the list # Prepending dependencies to the list
# Concatenation # Concatenation
# Minification # Minification
cat app/index.html \ cat app/app.html \
| grep script \ | grep script \
| grep -v bower \ | grep -v bower \
| cut -d '"' -f 2 \ | cut -d '"' -f 2 \
@ -30,7 +29,7 @@ dist:
echo app/bower_components/lodash/lodash.min.js && \ echo app/bower_components/lodash/lodash.min.js && \
cat ) \ cat ) \
| xargs cat \ | xargs cat \
| $(UGLIFY) > build/app.js | $(JSMIN) > build/app.js
# Compressing CSS # Compressing CSS
# #
@ -40,22 +39,11 @@ dist:
# Adding "app" prefix # Adding "app" prefix
# Concatenation # Concatenation
# Minification # Minification
cat app/index.html \ cat app/app.html \
| grep stylesheet \ | grep stylesheet \
| grep -v fonts.googleapis.com \
| grep -v opensans \ | grep -v opensans \
| cut -d '"' -f 4 \ | cut -d '"' -f 4 \
| sed -e 's/^/app/' \ | sed -e 's/^/app/' \
| xargs cat \ | xargs cat \
| $(CLEANCSS) -o build/app.css | $(CSSMIN) -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/<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,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

11
build/app.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf8">
<title>Empact</title>
<link rel="stylesheet" href="/app.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:400,600">
</head>
<body></body>
<script type="text/javascript" src="/app.js"></script>
</html>

View File

@ -1,16 +1,16 @@
upstream empact { 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 { server {
listen 80 default_server; listen 80 default_server;
root /home/empact/app/static; root /home/www/app/static;
charset utf-8; charset utf-8;
location / {
index hello.html;
}
location ~ ^/app/ { location ~ ^/app/ {
add_header Cache-Control private;
add_header X-UA-Compatible IE=edge; add_header X-UA-Compatible IE=edge;
add_header Content-Language en; add_header Content-Language en;
rewrite ^/app/(.*) /app.html last; rewrite ^/app/(.*) /app.html last;
@ -21,7 +21,9 @@ server {
} }
location /favicon.ico { 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)$ { location ~ .*\.(js|css|png)$ {
add_header Cache-Control public; add_header Cache-Control public;