From a76ba7512e0313e331f73ec2a11a103c047bc036 Mon Sep 17 00:00:00 2001 From: David Miller Date: Thu, 23 Jun 2016 16:22:57 -0400 Subject: [PATCH] Added minified JS, fixed banners, and updated readme with documentation on how to work with source files and use gulp tasks --- README.md | 12 +++++++++++- gulpfile.js | 28 +++++++++++++++++++++------- index.html | 2 +- js/agency.js | 6 ------ js/agency.min.js | 6 ++++++ package.json | 1 + 6 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 js/agency.min.js diff --git a/README.md b/README.md index 182b97e..7bee518 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,21 @@ ## Getting Started -To begin using this template, choose one of the following options to get started: +Several options are available to get started quickly: * [Download the latest release on Start Bootstrap](http://startbootstrap.com/template-overviews/agency/) * Clone the repo: `git clone https://github.com/BlackrockDigital/startbootstrap-agency.git` * Fork the repo +## Using Source Files + +To use the source files, you will need to have npm installed globally along with Gulp.js. To start: +* Run `npm install` in the root directory +* Run `gulp dev` and edit the files as needed + +If you need to update the plugins included with this template, simpy run the following tasks: +* First run `npm update` to update the dependencies +* Then run `gulp copy` to copy the new versions to their proper destinations + ## Bugs and Issues Have a bug or an issue with this template? [Open a new issue](https://github.com/BlackrockDigital/startbootstrap-agency/issues) here on GitHub or leave a comment on the [template overview page at Start Bootstrap](http://startbootstrap.com/template-overviews/agency/). diff --git a/gulpfile.js b/gulpfile.js index ef66582..ec80ce3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,6 +5,7 @@ var browserSync = require('browser-sync').create(); var header = require('gulp-header'); var cleanCSS = require('gulp-clean-css'); var rename = require("gulp-rename"); +var uglify = require('gulp-uglify'); var pkg = require('./package.json'); // Set the banner content @@ -36,26 +37,38 @@ gulp.task('less', function() { gulp.task('minify-css', function() { return gulp.src('css/agency.css') .pipe(cleanCSS({ compatibility: 'ie8' })) - .pipe(rename({suffix: '.min'})) + .pipe(rename({ suffix: '.min' })) .pipe(gulp.dest('css')) .pipe(browserSync.reload({ stream: true })) }); -// Grab Bootstrap core files from node_modules +// Minify JS +gulp.task('minify-js', function() { + return gulp.src('js/agency.js') + .pipe(uglify()) + .pipe(header(banner, { pkg: pkg })) + .pipe(rename({ suffix: '.min' })) + .pipe(gulp.dest('js')) + .pipe(browserSync.reload({ + stream: true + })) +}); + +// Copy Bootstrap core files from node_modules gulp.task('bootstrap', function() { return gulp.src(['node_modules/bootstrap/dist/**/*', '!**/npm.js', '!**/bootstrap-theme.*', '!**/*.map']) .pipe(gulp.dest('')) }) -// Grab jQuery core files from node_modules +// Copy jQuery core files from node_modules gulp.task('jquery', function() { return gulp.src(['node_modules/jquery/dist/jquery.js', 'node_modules/jquery/dist/jquery.min.js']) .pipe(gulp.dest('js')) }) -// Grab Font Awesome core files from node_modules +// Copy Font Awesome core files from node_modules gulp.task('fontawesome', function() { return gulp.src([ 'node_modules/font-awesome/**', @@ -68,8 +81,8 @@ gulp.task('fontawesome', function() { .pipe(gulp.dest('font-awesome')) }) -// Updates all dependencies and puts them into their proper destinations -gulp.task('update', ['bootstrap', 'jquery', 'fontawesome']); +// Copy all dependencies from node_modules +gulp.task('copy', ['bootstrap', 'jquery', 'fontawesome']); // Configure the browserSync task gulp.task('browserSync', function() { @@ -81,9 +94,10 @@ gulp.task('browserSync', function() { }) // Watch Task that compiles LESS and watches for HTML or JS changes and reloads with browserSync -gulp.task('watch', ['browserSync', 'less', 'minify-css'], function() { +gulp.task('dev', ['browserSync', 'less', 'minify-css', 'minify-js'], function() { gulp.watch('less/*.less', ['less']); gulp.watch('css/*.css', ['minify-css']); + gulp.watch('js/*.js', ['minify-js']); // Reloads the browser whenever HTML or JS files change gulp.watch('*.html', browserSync.reload); gulp.watch('js/**/*.js', browserSync.reload); diff --git a/index.html b/index.html index 3d46db3..6e7b7c1 100644 --- a/index.html +++ b/index.html @@ -446,7 +446,7 @@
- Copyright © Your Website 2014 + Copyright © Your Website 2016