From 735161a8ce3fa94b253fa62679ea2082f106d96a Mon Sep 17 00:00:00 2001 From: Carson Gee Date: Tue, 10 Mar 2015 17:55:03 -0400 Subject: [PATCH] Optimize asset pipeline for CSS and Javascript Create deterministic jasvascript loading Minify all JS into single file with ``build.py -p`` Minify all CSS into single file with ``build.py -p`` --- .gitignore | 2 + README.rst | 3 + Vagrantfile | 5 +- html_app/build.py | 92 +++++++++------ javascript_requirements.yml | 219 ++++++++++++++++++++++++++++++++++++ package.json | 18 +++ provision/ansible-dev.yml | 6 + provision/vagrant_env | 1 + requirements.txt | 2 + 9 files changed, 314 insertions(+), 34 deletions(-) create mode 100644 README.rst create mode 100644 javascript_requirements.yml create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 8dc7c274..ce7aa6e6 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,5 @@ static/ gen/ settings.yml + +node_modules/ \ No newline at end of file diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..7e6fdf38 --- /dev/null +++ b/README.rst @@ -0,0 +1,3 @@ +StarCellBio +=========== + diff --git a/Vagrantfile b/Vagrantfile index 9bfa1ab0..7633caec 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -26,7 +26,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # using a specific IP. config.vm.network "private_network", ip: "192.168.33.200" config.vm.network :forwarded_port, guest: 8100, host: 8100 - + config.vm.provider "virtualbox" do |vb| + vb.customize ["modifyvm", :id, "--memory", "1024"] + end # Create a public network, which generally matched to bridged network. # Bridged networks make the machine appear as another physical device on # your network. @@ -51,7 +53,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # vb.gui = true # # # Use VBoxManage to customize the VM. For example to change memory: - # vb.customize ["modifyvm", :id, "--memory", "1024"] # end # # View the documentation for the provider you're using for more diff --git a/html_app/build.py b/html_app/build.py index 96a5927b..16c5c76b 100755 --- a/html_app/build.py +++ b/html_app/build.py @@ -5,28 +5,36 @@ Usage: build.py build.py watch + build.py -p | --prod build.py -h | --help + Options: + -p --prod Do production javascript/css pipelining -h --help Show this help screen. """ import logging import os +import sh +from subprocess import call import time from docopt import docopt -from subprocess import call +from ordereddict import OrderedDict # For 2.6 compatibility from watchdog.observers import Observer from watchdog.events import RegexMatchingEventHandler - +import yaml ROOT = os.environ['PROJECT_HOME'] + '/html_app/' +JAVASCRIPT_REQUIREMENTS = 'javascript_requirements.yml' +prod_minify = False global_update_index = True js = dict() css = dict() + TIME = '?_=' + str(int(time.time())) CSS_PREFIX = '=0.8.3 docopt>=0.6.2 +ordereddict>=1.1 +sh>=1.11