Skip to content

Commit

Permalink
Using npm ecosystem to build and minify JavaScript.
Browse files Browse the repository at this point in the history
  • Loading branch information
dacox committed Oct 6, 2015
1 parent 4243c54 commit 0f1dd41
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source: src
destination: _site

# The name of your website.
name: Dribs and Drabs
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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 <self@dacox.net>"
Expand Down
45 changes: 43 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dacox.net",
"version": "0.0.0",
"version": "0.1.0",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand All @@ -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"
}
}
2 changes: 1 addition & 1 deletion src/_includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<script src="{{ site.baseurl }}/js/modernizr.js"></script>
<script src="{{ site.baseurl }}/js/fitvids.js"></script>
-->
<script src="{{ site.baseurl }}/js/a.js"></script>
<script src="{{ site.baseurl }}/js/all.min.js"></script>
<link href='//fonts.googleapis.com/css?family=Source+Code+Pro:400,700|Source+Sans+Pro:600,900|Crimson+Text:700italic,600,600italic,400,700,400italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="{{ site.baseurl }}/css/reset.css">
<link rel="stylesheet" href="{{ site.baseurl }}/css/pygments.css">
Expand Down

0 comments on commit 0f1dd41

Please sign in to comment.