2018-12-23 05:53:41 +01:00
|
|
|
// 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');
|
2016-06-22 00:23:31 +02:00
|
|
|
|
2016-06-22 22:39:59 +02:00
|
|
|
// Set the banner content
|
2018-12-23 05:53:41 +01:00
|
|
|
const banner = ['/*!\n',
|
2017-08-11 21:12:34 +02:00
|
|
|
' * 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',
|
|
|
|
' */\n',
|
2018-08-24 00:21:13 +02:00
|
|
|
'\n'
|
2016-06-22 22:39:59 +02:00
|
|
|
].join('');
|
|
|
|
|
2018-01-20 00:37:06 +01:00
|
|
|
// Copy third party libraries from /node_modules into /vendor
|
2018-12-23 05:53:41 +01:00
|
|
|
gulp.task('vendor', function(cb) {
|
2018-01-20 00:37:06 +01:00
|
|
|
|
|
|
|
// Bootstrap
|
|
|
|
gulp.src([
|
|
|
|
'./node_modules/bootstrap/dist/**/*',
|
|
|
|
'!./node_modules/bootstrap/dist/css/bootstrap-grid*',
|
|
|
|
'!./node_modules/bootstrap/dist/css/bootstrap-reboot*'
|
|
|
|
])
|
|
|
|
.pipe(gulp.dest('./vendor/bootstrap'))
|
|
|
|
|
|
|
|
// Font Awesome
|
|
|
|
gulp.src([
|
2018-08-24 00:21:13 +02:00
|
|
|
'./node_modules/@fortawesome/**/*',
|
2018-01-20 00:37:06 +01:00
|
|
|
])
|
2018-08-24 00:21:13 +02:00
|
|
|
.pipe(gulp.dest('./vendor'))
|
2018-01-20 00:37:06 +01:00
|
|
|
|
|
|
|
// jQuery
|
|
|
|
gulp.src([
|
|
|
|
'./node_modules/jquery/dist/*',
|
|
|
|
'!./node_modules/jquery/dist/core.js'
|
|
|
|
])
|
|
|
|
.pipe(gulp.dest('./vendor/jquery'))
|
|
|
|
|
|
|
|
// jQuery Easing
|
|
|
|
gulp.src([
|
|
|
|
'./node_modules/jquery.easing/*.js'
|
|
|
|
])
|
|
|
|
.pipe(gulp.dest('./vendor/jquery-easing'))
|
|
|
|
|
2018-12-23 05:53:41 +01:00
|
|
|
cb();
|
|
|
|
|
2016-06-22 22:39:59 +02:00
|
|
|
});
|
|
|
|
|
2018-12-23 05:53:41 +01:00
|
|
|
// CSS task
|
|
|
|
function css() {
|
|
|
|
return gulp
|
|
|
|
.src("./scss/*.scss")
|
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(sass({
|
|
|
|
outputStyle: "expanded"
|
|
|
|
}))
|
|
|
|
.on("error", sass.logError)
|
2018-08-24 00:21:13 +02:00
|
|
|
.pipe(autoprefixer({
|
|
|
|
browsers: ['last 2 versions'],
|
|
|
|
cascade: false
|
|
|
|
}))
|
2018-05-03 07:38:23 +02:00
|
|
|
.pipe(header(banner, {
|
|
|
|
pkg: pkg
|
|
|
|
}))
|
2018-12-23 05:53:41 +01:00
|
|
|
.pipe(gulp.dest("./css"))
|
2017-08-11 21:12:34 +02:00
|
|
|
.pipe(rename({
|
2018-12-23 05:53:41 +01:00
|
|
|
suffix: ".min"
|
2017-08-11 21:12:34 +02:00
|
|
|
}))
|
2018-12-23 05:53:41 +01:00
|
|
|
.pipe(cleanCSS())
|
|
|
|
.pipe(gulp.dest("./css"))
|
|
|
|
.pipe(browsersync.stream());
|
|
|
|
}
|
2018-01-20 00:37:06 +01:00
|
|
|
|
2018-12-23 05:53:41 +01:00
|
|
|
// JS task
|
|
|
|
function js() {
|
|
|
|
return gulp
|
|
|
|
.src([
|
2018-01-20 00:37:06 +01:00
|
|
|
'./js/*.js',
|
2018-12-23 05:53:41 +01:00
|
|
|
'!./js/*.min.js',
|
|
|
|
'!./js/contact_me.js',
|
|
|
|
'!./js/jqBootstrapValidation.js'
|
2018-01-20 00:37:06 +01:00
|
|
|
])
|
2017-08-11 21:12:34 +02:00
|
|
|
.pipe(uglify())
|
2018-05-03 07:38:23 +02:00
|
|
|
.pipe(header(banner, {
|
|
|
|
pkg: pkg
|
|
|
|
}))
|
2018-12-23 05:53:41 +01:00
|
|
|
.pipe(rename({
|
|
|
|
suffix: '.min'
|
|
|
|
}))
|
2018-01-20 00:37:06 +01:00
|
|
|
.pipe(gulp.dest('./js'))
|
2018-12-23 05:53:41 +01:00
|
|
|
.pipe(browsersync.stream());
|
|
|
|
}
|
2016-06-22 00:23:31 +02:00
|
|
|
|
2018-12-23 05:53:41 +01:00
|
|
|
// Tasks
|
|
|
|
gulp.task("css", css);
|
|
|
|
gulp.task("js", js);
|
2016-06-22 00:23:31 +02:00
|
|
|
|
2018-12-23 05:53:41 +01:00
|
|
|
// BrowserSync
|
|
|
|
function browserSync(done) {
|
|
|
|
browsersync.init({
|
2017-08-11 21:12:34 +02:00
|
|
|
server: {
|
2018-01-20 00:37:06 +01:00
|
|
|
baseDir: "./"
|
|
|
|
}
|
|
|
|
});
|
2018-12-23 05:53:41 +01:00
|
|
|
done();
|
|
|
|
}
|
2016-06-22 00:23:31 +02:00
|
|
|
|
2018-12-23 05:53:41 +01:00
|
|
|
// 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));
|