From 1cee2677d36b5046b14dbdbed48a09d44e4e4be6 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 24 Nov 2016 15:07:22 +0000 Subject: [PATCH] setup static build step --- .gitignore | 4 ++++ package.json | 4 +++- requirements.txt | 1 + scripts/build-js.sh | 20 ++++++++++---------- scripts/build-scss.sh | 8 ++++---- static/js/project.js | 0 static/{css/project.css => src/js/app.js} | 0 static/src/scss/index.scss | 1 + 8 files changed, 23 insertions(+), 15 deletions(-) delete mode 100755 static/js/project.js rename static/{css/project.css => src/js/app.js} (100%) create mode 100755 static/src/scss/index.scss diff --git a/.gitignore b/.gitignore index 2f772e4..242fb36 100644 --- a/.gitignore +++ b/.gitignore @@ -165,3 +165,7 @@ jspm_packages # .nfs files are created when an open file is removed but is still being accessed .nfs* + + +### Custom ### +static/src/scss/pygment.css diff --git a/package.json b/package.json index 1279b45..5aa5996 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,10 @@ "version": "5.0.0", "description": " Source code for TheOrangeOne.net", "scripts": { + "create-build-dirs": "mkdir -p static/build/js/lib static/build/fonts static/build/css static/build/img", "build-js": "./scripts/build-js.sh", - "build-scss": "./scripts/build-scss.sh" + "build-scss": "./scripts/build-scss.sh", + "build": "npm run create-build-dirs && npm run build-scss && npm run build-js" }, "repository": { "type": "git", diff --git a/requirements.txt b/requirements.txt index e13f199..8758eef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,6 @@ coverage==4.2 Django>=1.10,<1.11 flake8==3.2.1 honcho==0.7.1 +pygments-style-github==0.4 wagtail>=1.7,<1.8 whitenoise==3.2.2 diff --git a/scripts/build-js.sh b/scripts/build-js.sh index 2071800..5425a34 100755 --- a/scripts/build-js.sh +++ b/scripts/build-js.sh @@ -7,38 +7,38 @@ then echo ">>> WARNING: Building in Production Mode!" fi -mkdir -p theme/static/build/js/lib +mkdir -p static/build/js/lib if [ "$NODE_ENV" = "production" ] then echo ">> Compressing Libraries..." - uglifyjs node_modules/bootstrap-sass/assets/javascripts/bootstrap.js --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/lib/bootstrap.js - uglifyjs theme/static/build/js/lib/* --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/libs.js + uglifyjs node_modules/bootstrap-sass/assets/javascripts/bootstrap.js --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/lib/bootstrap.js + uglifyjs static/build/js/lib/* --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/libs.js else echo ">> Building Libraries..." - cp node_modules/bootstrap-sass/assets/javascripts/bootstrap.js theme/static/build/js/lib/bootstrap.js - uglifyjs theme/static/build/js/lib/* --screw-ie8 --stats --keep-fnames -o theme/static/build/js/libs.js + cp node_modules/bootstrap-sass/assets/javascripts/bootstrap.js static/build/js/lib/bootstrap.js + uglifyjs static/build/js/lib/* --screw-ie8 --stats --keep-fnames -o static/build/js/libs.js fi -rm -rf theme/static/build/js/lib +rm -rf static/build/js/lib if [ "$NODE_ENV" = "production" ] then echo ">> Compressing jQuery..." - uglifyjs node_modules/jquery/dist/jquery.js --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/jquery.js + uglifyjs node_modules/jquery/dist/jquery.js --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/jquery.js else echo ">> Building jQuery..." - cp node_modules/jquery/dist/jquery.js theme/static/build/js/jquery.js + cp node_modules/jquery/dist/jquery.js static/build/js/jquery.js fi echo ">> Building Application JS..." -browserify -t [ babelify --presets [ es2015 react ] ] theme/static/src/js/app.js -o theme/static/build/js/app.js +browserify -t [ babelify --presets [ es2015 react ] ] static/src/js/app.js -o static/build/js/app.js if [ "$NODE_ENV" = "production" ] then echo ">> Compressing Application..." - uglifyjs theme/static/build/js/app.js --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/app.js + uglifyjs static/build/js/app.js --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/app.js fi echo "> JS Built!" diff --git a/scripts/build-scss.sh b/scripts/build-scss.sh index 164454a..e6c6e9b 100755 --- a/scripts/build-scss.sh +++ b/scripts/build-scss.sh @@ -8,16 +8,16 @@ then fi echo ">> Generating Pygments styles..." -env/bin/pygmentize -S github -f html -a .highlight > theme/static/src/scss/pygment.css +env/bin/pygmentize -S github -f html -a .highlight > static/src/scss/pygment.css echo ">> Building SCSS..." -node-sass theme/static/src/scss/index.scss theme/static/build/css/index.css --source-map-embed +node-sass static/src/scss/index.scss static/build/css/index.css --source-map-embed echo ">> Post-Processing..." -postcss -u autoprefixer -o theme/static/build/css/index.css theme/static/build/css/index.css +postcss -u autoprefixer -o static/build/css/index.css static/build/css/index.css if [ "$NODE_ENV" = "production" ] then echo ">> Compressing CSS..." - cleancss -d --s0 -o theme/static/build/css/index.css theme/static/build/css/index.css + cleancss -d --s0 -o static/build/css/index.css static/build/css/index.css fi diff --git a/static/js/project.js b/static/js/project.js deleted file mode 100755 index e69de29..0000000 diff --git a/static/css/project.css b/static/src/js/app.js similarity index 100% rename from static/css/project.css rename to static/src/js/app.js diff --git a/static/src/scss/index.scss b/static/src/scss/index.scss new file mode 100755 index 0000000..777fe93 --- /dev/null +++ b/static/src/scss/index.scss @@ -0,0 +1 @@ +@import 'pygment';