2016-06-22 00:23:31 +02:00
|
|
|
var gulp = require('gulp');
|
|
|
|
var less = require('gulp-less');
|
2016-08-19 21:48:30 +02:00
|
|
|
var sass = require('gulp-sass');
|
2016-06-22 00:23:31 +02:00
|
|
|
var browserSync = require('browser-sync').create();
|
2016-06-22 22:39:59 +02:00
|
|
|
var header = require('gulp-header');
|
|
|
|
var cleanCSS = require('gulp-clean-css');
|
|
|
|
var rename = require("gulp-rename");
|
2016-06-23 22:22:57 +02:00
|
|
|
var uglify = require('gulp-uglify');
|
2016-06-22 22:39:59 +02:00
|
|
|
var pkg = require('./package.json');
|
2016-06-22 00:23:31 +02:00
|
|
|
|
2016-06-22 22:39:59 +02:00
|
|
|
// Set the banner content
|
|
|
|
var banner = ['/*!\n',
|
|
|
|
' * Start Bootstrap - <%= pkg.title %> v<%= pkg.version %> (<%= pkg.homepage %>)\n',
|
|
|
|
' * Copyright 2013-' + (new Date()).getFullYear(), ' <%= pkg.author %>\n',
|
|
|
|
' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n',
|
|
|
|
' */\n',
|
|
|
|
''
|
|
|
|
].join('');
|
|
|
|
|
2016-08-19 21:48:30 +02:00
|
|
|
// Compile LESS files from /less into /css
|
2016-06-22 00:23:31 +02:00
|
|
|
gulp.task('less', function() {
|
2017-01-21 02:24:00 +01:00
|
|
|
return gulp.src('stylesheets/less/agency.less')
|
2016-06-22 00:23:31 +02:00
|
|
|
.pipe(less())
|
2016-06-22 22:39:59 +02:00
|
|
|
.pipe(header(banner, { pkg: pkg }))
|
2017-01-21 02:24:00 +01:00
|
|
|
.pipe(gulp.dest('stylesheets/css'))
|
2016-06-22 22:39:59 +02:00
|
|
|
.pipe(browserSync.reload({
|
|
|
|
stream: true
|
|
|
|
}))
|
|
|
|
});
|
|
|
|
|
2016-08-19 21:48:30 +02:00
|
|
|
// Minify compiled CSS
|
2016-08-19 04:18:56 +02:00
|
|
|
gulp.task('minify-css', ['less'], function() {
|
2017-01-21 02:24:00 +01:00
|
|
|
return gulp.src('stylesheets/css/agency.css')
|
2016-06-22 22:39:59 +02:00
|
|
|
.pipe(cleanCSS({ compatibility: 'ie8' }))
|
2016-06-23 22:22:57 +02:00
|
|
|
.pipe(rename({ suffix: '.min' }))
|
2017-01-21 02:24:00 +01:00
|
|
|
.pipe(gulp.dest('stylesheets/css'))
|
2016-06-22 00:23:31 +02:00
|
|
|
.pipe(browserSync.reload({
|
|
|
|
stream: true
|
|
|
|
}))
|
|
|
|
});
|
|
|
|
|
2016-06-23 22:22:57 +02:00
|
|
|
// 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
|
|
|
|
}))
|
|
|
|
});
|
|
|
|
|
2016-08-19 21:48:30 +02:00
|
|
|
// Copy vendor libraries from /node_modules into /vendor
|
|
|
|
gulp.task('copy', function() {
|
|
|
|
gulp.src(['node_modules/bootstrap/dist/**/*', '!**/npm.js', '!**/bootstrap-theme.*', '!**/*.map'])
|
2017-01-21 02:24:00 +01:00
|
|
|
.pipe(gulp.dest('lib/bootstrap'))
|
2016-06-22 00:23:31 +02:00
|
|
|
|
2016-08-19 21:48:30 +02:00
|
|
|
gulp.src(['node_modules/jquery/dist/jquery.js', 'node_modules/jquery/dist/jquery.min.js'])
|
2017-01-21 02:24:00 +01:00
|
|
|
.pipe(gulp.dest('lib/jquery'))
|
2016-06-22 00:23:31 +02:00
|
|
|
|
2016-11-30 03:03:56 +01:00
|
|
|
gulp.src(['node_modules/tether/dist/js/tether.js', 'node_modules/tether/dist/js/tether.min.js'])
|
2017-01-21 02:24:00 +01:00
|
|
|
.pipe(gulp.dest('lib/tether'))
|
2016-11-30 03:03:56 +01:00
|
|
|
|
2016-08-19 21:48:30 +02:00
|
|
|
gulp.src([
|
2016-06-22 00:23:31 +02:00
|
|
|
'node_modules/font-awesome/**',
|
|
|
|
'!node_modules/font-awesome/**/*.map',
|
|
|
|
'!node_modules/font-awesome/.npmignore',
|
|
|
|
'!node_modules/font-awesome/*.txt',
|
|
|
|
'!node_modules/font-awesome/*.md',
|
|
|
|
'!node_modules/font-awesome/*.json'
|
|
|
|
])
|
2017-01-21 02:24:00 +01:00
|
|
|
.pipe(gulp.dest('lib/font-awesome'))
|
2016-06-22 00:23:31 +02:00
|
|
|
})
|
|
|
|
|
2016-08-19 21:48:30 +02:00
|
|
|
// Run everything
|
|
|
|
gulp.task('default', ['less', 'minify-css', 'minify-js', 'copy']);
|
2016-06-22 00:23:31 +02:00
|
|
|
|
2016-06-22 22:39:59 +02:00
|
|
|
// Configure the browserSync task
|
2016-06-22 00:23:31 +02:00
|
|
|
gulp.task('browserSync', function() {
|
|
|
|
browserSync.init({
|
|
|
|
server: {
|
|
|
|
baseDir: ''
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2016-08-19 22:02:27 +02:00
|
|
|
// Dev task with browserSync
|
|
|
|
gulp.task('dev', ['browserSync', 'less', 'minify-css', 'minify-js'], function() {
|
2017-01-21 02:24:00 +01:00
|
|
|
gulp.watch('stylesheets/less/*.less', ['less']);
|
|
|
|
gulp.watch('stylesheets/css/*.css', ['minify-css']);
|
2016-06-23 22:22:57 +02:00
|
|
|
gulp.watch('js/*.js', ['minify-js']);
|
2016-06-22 00:23:31 +02:00
|
|
|
// Reloads the browser whenever HTML or JS files change
|
|
|
|
gulp.watch('*.html', browserSync.reload);
|
|
|
|
gulp.watch('js/**/*.js', browserSync.reload);
|
2016-08-19 21:48:30 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// Compiles SCSS files from /scss into /css
|
|
|
|
// NOTE: This theme uses LESS by default. To swtich to SCSS you will need to update this gulpfile by changing the 'less' tasks to run 'sass'!
|
|
|
|
gulp.task('sass', function() {
|
2017-01-21 02:24:00 +01:00
|
|
|
return gulp.src('stylesheets/scss/agency.scss')
|
2016-08-19 21:48:30 +02:00
|
|
|
.pipe(sass())
|
|
|
|
.pipe(header(banner, { pkg: pkg }))
|
2017-01-21 02:24:00 +01:00
|
|
|
.pipe(gulp.dest('stylesheets/css'))
|
2016-08-19 21:48:30 +02:00
|
|
|
.pipe(browserSync.reload({
|
|
|
|
stream: true
|
|
|
|
}))
|
|
|
|
});
|