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

69 lines
1.9 KiB
JavaScript
Raw Normal View History

2016-01-04 11:36:14 +00:00
'use strict';
var gulp = require('gulp'),
2016-01-05 23:21:51 +00:00
plugins = require('gulp-load-plugins')(),
del = require('del');
2016-01-04 11:36:14 +00:00
2016-01-04 17:11:19 +00:00
var config = {
2016-01-09 17:20:23 +00:00
bowerDir: 'vendor/bower',
2016-01-08 01:44:44 +00:00
assetsDir: './source/assets',
sassPattern: './sass/**/*.scss',
production: !!plugins.util.env.production,
2016-01-08 01:44:44 +00:00
sourceMaps: !plugins.util.env.production,
2016-01-08 09:36:38 +00:00
liveReload: !plugins.util.env.production
2016-01-04 17:11:19 +00:00
};
2016-01-08 01:44:44 +00:00
var app = {};
app.addStyle = function(paths, filename) {
gulp.src(paths)
.pipe(plugins.plumber())
.pipe(plugins.if(config.sourceMaps, plugins.sourcemaps.init()))
.pipe(plugins.sass())
.pipe(plugins.concat(filename))
.pipe(config.production ? plugins.minifyCss() : plugins.util.noop())
.pipe(plugins.if(config.sourceMaps, plugins.sourcemaps.write('.')))
.pipe(gulp.dest(config.assetsDir + '/css'))
2016-01-08 11:32:22 +00:00
.pipe(plugins.if(config.liveReload, plugins.livereload()));
2016-01-08 09:36:38 +00:00
};
2016-01-08 01:44:44 +00:00
app.copy = function(srcFiles, outputDir) {
gulp.src(srcFiles)
.pipe(gulp.dest(outputDir));
2016-01-08 09:36:38 +00:00
};
2016-01-08 01:44:44 +00:00
gulp.task('fonts', function () {
// Copy fonts from bower_components into source/asset/fonts.
app.copy(config.bowerDir + '/font-awesome/fonts/*', config.assetsDir + '/fonts');
});
2016-01-05 23:13:07 +00:00
gulp.task('styles', function () {
2016-01-08 01:44:44 +00:00
app.addStyle([
config.bowerDir + '/font-awesome/css/font-awesome.css',
'./sass/styles.scss'
], 'all.css')
2016-01-04 12:20:00 +00:00
});
2016-01-05 18:57:18 +00:00
gulp.task('images', function () {
2016-01-04 11:38:34 +00:00
// Minify images.
2016-01-05 18:57:18 +00:00
gulp.src(config.imagesDir + '/*')
2016-01-04 17:07:01 +00:00
.pipe(plugins.imagemin())
2016-01-04 17:11:19 +00:00
.pipe(gulp.dest(config.imagesDir));
2016-01-04 11:36:14 +00:00
});
2016-01-04 12:20:00 +00:00
gulp.task('watch', function () {
2016-01-08 01:44:44 +00:00
plugins.livereload.listen();
2016-01-05 23:13:07 +00:00
gulp.watch(config.sassPattern, ['styles']);
2016-01-04 12:20:00 +00:00
});
2016-01-05 23:21:51 +00:00
gulp.task('clean', function () {
2016-01-08 01:44:44 +00:00
del.sync(config.assetsDir + '/css');
del.sync(config.assetsDir + '/fonts');
2016-01-05 23:21:51 +00:00
del.sync('./output_*/assets/css/*');
2016-01-08 01:44:44 +00:00
del.sync('./output_*/assets/fonts/*');
2016-01-05 23:21:51 +00:00
});
2016-01-08 11:34:38 +00:00
gulp.task('build', ['clean', 'styles', 'fonts']);
gulp.task('default', ['build', 'watch']);