Skip to content

Commit

Permalink
update dependencies and gulpfile.js to gulp 4
Browse files Browse the repository at this point in the history
bootstrap 4.2.1, font awesome 5.6.3, gulp 4, and gulpfile rewritten for gulp 4
  • Loading branch information
davidtmiller committed Dec 23, 2018
1 parent db79f63 commit 8ae533b
Show file tree
Hide file tree
Showing 1,557 changed files with 20,767 additions and 21,432 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
sudo: false
language: node_js
git:
depth: 3
node_js:
- "node"
install: npm install
Expand All @@ -9,3 +10,5 @@ script:
cache:
directories:
- node_modules
notifications:
email: false
125 changes: 67 additions & 58 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
var gulp = require('gulp');
var sass = require('gulp-sass');
var header = require('gulp-header');
var cleanCSS = require('gulp-clean-css');
var rename = require("gulp-rename");
var uglify = require('gulp-uglify');
var autoprefixer = require('gulp-autoprefixer');
var pkg = require('./package.json');
var browserSync = require('browser-sync').create();
// Load plugins
const autoprefixer = require("gulp-autoprefixer");
const browsersync = require("browser-sync").create();
const cleanCSS = require("gulp-clean-css");
const gulp = require("gulp");
const header = require("gulp-header");
const plumber = require("gulp-plumber");
const rename = require("gulp-rename");
const sass = require("gulp-sass");
const uglify = require("gulp-uglify");
const pkg = require('./package.json');

// Set the banner content
var banner = ['/*!\n',
const banner = ['/*!\n',
' * Start Bootstrap - <%= pkg.title %> v<%= pkg.version %> (<%= pkg.homepage %>)\n',
' * Copyright 2013-' + (new Date()).getFullYear(), ' <%= pkg.author %>\n',
' * Licensed under <%= pkg.license %> (https://github.com/BlackrockDigital/<%= pkg.name %>/blob/master/LICENSE)\n',
Expand All @@ -18,7 +20,7 @@ var banner = ['/*!\n',
].join('');

// Copy third party libraries from /node_modules into /vendor
gulp.task('vendor', function() {
gulp.task('vendor', function(cb) {

// Bootstrap
gulp.src([
Expand All @@ -41,76 +43,83 @@ gulp.task('vendor', function() {
])
.pipe(gulp.dest('./vendor/jquery'))

cb();

});

// Compile SCSS
gulp.task('css:compile', function() {
return gulp.src('./scss/**/*.scss')
.pipe(sass.sync({
outputStyle: 'expanded'
}).on('error', sass.logError))
// CSS task
function css() {
return gulp
.src("./scss/*.scss")
.pipe(plumber())
.pipe(sass({
outputStyle: "expanded"
}))
.on("error", sass.logError)
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(header(banner, {
pkg: pkg
}))
.pipe(gulp.dest('./css'))
});

// Minify CSS
gulp.task('css:minify', ['css:compile'], function() {
return gulp.src([
'./css/*.css',
'!./css/*.min.css'
])
.pipe(cleanCSS())
.pipe(gulp.dest("./css"))
.pipe(rename({
suffix: '.min'
suffix: ".min"
}))
.pipe(gulp.dest('./css'))
.pipe(browserSync.stream());
});

// CSS
gulp.task('css', ['css:compile', 'css:minify']);
.pipe(cleanCSS())
.pipe(gulp.dest("./css"))
.pipe(browsersync.stream());
}

// Minify JavaScript
gulp.task('js:minify', function() {
return gulp.src([
// JS task
function js() {
return gulp
.src([
'./js/*.js',
'!./js/*.min.js'
'!./js/*.min.js',
'!./js/contact_me.js',
'!./js/jqBootstrapValidation.js'
])
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(header(banner, {
pkg: pkg
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./js'))
.pipe(browserSync.stream());
});

// JS
gulp.task('js', ['js:minify']);
.pipe(browsersync.stream());
}

// Default task
gulp.task('default', ['css', 'js', 'vendor']);
// Tasks
gulp.task("css", css);
gulp.task("js", js);

// Configure the browserSync task
gulp.task('browserSync', function() {
browserSync.init({
// BrowserSync
function browserSync(done) {
browsersync.init({
server: {
baseDir: "./"
}
});
});
done();
}

// Dev task
gulp.task('dev', ['css', 'js', 'browserSync'], function() {
gulp.watch('./scss/*.scss', ['css']);
gulp.watch('./js/*.js', ['js']);
gulp.watch('./*.html', browserSync.reload);
});
// BrowserSync Reload
function browserSyncReload(done) {
browsersync.reload();
done();
}

// Watch files
function watchFiles() {
gulp.watch("./scss/**/*", css);
gulp.watch(["./js/**/*.js", "!./js/*.min.js"], js);
gulp.watch("./**/*.html", browserSyncReload);
}

gulp.task("default", gulp.parallel('vendor', css, js));

// dev task
gulp.task("dev", gulp.parallel(watchFiles, browserSync));
Loading

0 comments on commit 8ae533b

Please sign in to comment.