This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
oliverdavies.uk-old-sculpin/gulpfile.js
2016-12-13 22:56:33 +00:00

84 lines
2.4 KiB
JavaScript

'use strict';
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var config = require('./gulpfile.config.js')(plugins);
var del = require('del');
var app = {};
app.sass = function(paths, filename) {
return gulp.src(paths)
.pipe(plugins.plumber())
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
.pipe(plugins.sassGlob())
.pipe(plugins.sass({
outputStyle: 'compressed'
}))
.pipe(plugins.autoprefixer({
browsers: config.autoprefixer.browsers,
cascade: false
}))
.pipe(plugins.concat(filename))
.pipe(plugins.if(!config.production, plugins.sourcemaps.write('.')))
.pipe(plugins.if(!config.production, plugins.refresh()))
.pipe(gulp.dest(config.sass.outputDir));
};
app.js = function(paths, filename) {
return gulp.src(paths)
.pipe(plugins.plumber())
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
.pipe(plugins.concat(filename))
.pipe(plugins.if(config.production, plugins.uglify()))
.pipe(plugins.if(!config.production, plugins.sourcemaps.write('.')))
.pipe(gulp.dest(config.js.outputDir));
};
app.copy = function(source, destination) {
return gulp.src(source)
.pipe(gulp.dest(destination));
};
gulp.task('clean', function() {
del.sync(config.fontsDir);
del.sync(config.js.outputDir);
del.sync(config.sass.outputDir);
del.sync('output_*/assets/css');
del.sync('output_*/assets/fonts');
del.sync('output_*/assets/js');
});
gulp.task('fonts', function() {
return app.copy(
config.bowerDir + "/font-awesome/fonts/*",
config.fontsDir
);
});
gulp.task('styles', function() {
return app.sass([
config.bowerDir + '/font-awesome/css/font-awesome.css',
config.sass.sourceDir + config.sass.pattern
], 'site.css');
});
gulp.task('scripts', function() {
return app.js([
config.bowerDir + '/jquery2/jquery.js',
config.bowerDir + '/bootstrap-sass/assets/javascripts/bootstrap.js',
config.js.sourceDir + config.js.pattern
], 'site.js');
});
gulp.task('build', ['clean', 'fonts', 'styles', 'scripts']);
gulp.task('default', ['build']);
gulp.task('watch', ['build'], function() {
plugins.refresh.listen();
gulp.watch(config.sass.sourceDir + config.sass.pattern, ['styles']);
gulp.watch(config.js.sourceDir + config.js.pattern, ['scripts']);
});