From 0f1dd41d081f494245c3597fb93190b315c7571e Mon Sep 17 00:00:00 2001 From: Doug Cox Date: Mon, 5 Oct 2015 18:50:25 -0700 Subject: [PATCH] Using npm ecosystem to build and minify JavaScript. --- _config.yml | 2 ++ bower.json | 2 +- gulpfile.js | 45 +++++++++++++++++++++++++++++++++++++++-- package.json | 9 +++++++-- src/_includes/head.html | 2 +- 5 files changed, 54 insertions(+), 6 deletions(-) diff --git a/_config.yml b/_config.yml index 993cd140..ff4f6bba 100644 --- a/_config.yml +++ b/_config.yml @@ -1,3 +1,5 @@ +source: src +destination: _site # The name of your website. name: Dribs and Drabs diff --git a/bower.json b/bower.json index 72343326..2eda2a74 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "dacox.net", - "version": "0.0.0", + "version": "0.1.0", "homepage": "/~https://github.com/dacox/dacox.net", "authors": [ "Doug Cox " diff --git a/gulpfile.js b/gulpfile.js index 8478fc9f..556efc0b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,9 +2,50 @@ var gulp = require('gulp'); /* include plugins */ -var cp = require('child_process'); +var cp = require('child_process'), + concat = require('gulp-concat'), + connect = require('gulp-connect'), + gzip = require('gulp-gzip'), + //minifycss = require('gulp-minify-css'), + //injectreload = require('gulp-inject-reload'), + //inlinesource = require('gulp-inline-source'), + //jshint = require('gulp-jshint'), + //less = require('gulp-less'), + //livereload = require('gulp-livereload'), + //minifyhtml = require('gulp-minify-html'), + os = require('os'), + rename = require('gulp-rename'), + //sass = require('gulp-sass'), + uglify = require('gulp-uglify'); + //uncss = require('gulp-uncss'), + //zopfli = require('gulp-zopfli'), + //es = require('event-stream'); + +gulp.task('connect', function() { + connect.server({ + root: '_site', + port: 8000 + }); +}); gulp.task('jekyll', function(done) { - return cp.spawn('bundle', ['exec', 'jekyll', 'build', '-q', '--source=.', '--destination=_build', '--config=_config.yml'], { stdio: 'inherit' }) + return cp.spawn('bundle', ['exec', 'jekyll', 'build', '-q', '--config=_config.yml'], { stdio: 'inherit' }) .on('close', done); }); + +gulp.task('js', function() { + return gulp.src(['bower_components/jquery/dist/jquery.js', + 'bower_components/jquery.fitvids/jquery.fitvids.js', + 'bower_components/modernizr/modernizr.js']) + .pipe(concat('all.js')) + .pipe(gulp.dest('_site/js')) + .pipe(rename('all.min.js')) + .pipe(uglify()) + .pipe(gulp.dest('_site/js')) + .pipe(gzip({append:true,threshold:false,gzipOptions:{level:9,memLevel:1}})) + .pipe(rename('all.min.jsz')) + .pipe(gulp.dest('_site/js')); +}); + +gulp.task('default', ['jekyll', 'js']); + diff --git a/package.json b/package.json index b32aea11..060f5caa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dacox.net", - "version": "0.0.0", + "version": "0.1.0", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -12,6 +12,11 @@ "license": "MIT", "devDependencies": { "gulp": "~3.9.0", - "bower": "~1.5.2" + "bower": "~1.5.2", + "gulp-concat": "~2.6.0", + "gulp-uglify": "~1.4.0", + "gulp-gzip": "~1.2.0", + "gulp-rename": "~1.2.2", + "gulp-connect": "~2.2.0" } } diff --git a/src/_includes/head.html b/src/_includes/head.html index 1d6638bf..72bed821 100644 --- a/src/_includes/head.html +++ b/src/_includes/head.html @@ -48,7 +48,7 @@ --> - +