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
2017-09-05 00:27:07 +01:00

82 lines
2.6 KiB
JavaScript

'use strict';
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var config = require('./gulpfile.config')(plugins);
var del = require('del');
var app = {};
app.copy = function (sourceFiles, destination) {
return gulp.src(sourceFiles)
.pipe(gulp.dest(destination));
};
app.sass = function (sourceFiles, outputFile) {
return gulp.src(sourceFiles)
.pipe(plugins.plumber())
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
.pipe(plugins.sassGlob())
.pipe(plugins.sass())
.pipe(plugins.autoprefixer(config.sass.autoprefixer))
.pipe(plugins.concat(outputFile))
.pipe(plugins.if(config.production, plugins.purifycss(config.sass.purifyCss)))
.pipe(plugins.if(config.production, plugins.cleanCss()))
.pipe(plugins.if(!config.production, plugins.sourcemaps.write('.')))
.pipe(plugins.if(!config.production, plugins.refresh()))
.pipe(gulp.dest(config.sass.outputDir));
};
app.js = function (sourceFiles, outputFile) {
return gulp.src(sourceFiles)
.pipe(plugins.plumber())
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
.pipe(plugins.concat(outputFile))
.pipe(plugins.if(config.production, plugins.uglify()))
.pipe(plugins.if(!config.production, plugins.sourcemaps.write('.')))
.pipe(gulp.dest(config.js.outputDir));
};
gulp.task('clean', function () {
del.sync('source/assets/{css,fonts,js}');
del.sync('output_*/assets/{css,fonts,js}');
});
gulp.task('default', ['clean', 'fonts', 'styles', 'scripts']);
gulp.task('fonts', function () {
return app.copy('node_modules/font-awesome/fonts/*', config.fonts.outputDir);
});
gulp.task('styles', function () {
app.sass([
'node_modules/font-awesome/css/font-awesome.css',
config.sass.sourceDir + '/main.sass'
], 'main.css');
app.sass([
'node_modules/prismjs/themes/prism-twilight.css',
config.sass.sourceDir + '/post.sass'
], 'post.css')
});
gulp.task('scripts', function () {
app.js([
'node_modules/jquery/dist/jquery.js',
config.js.sourceDir + '/**/*.js'
], 'main.js')
app.js([
'node_modules/jquery/dist/jquery.js',
'node_modules/prismjs/prism.js',
'node_modules/prismjs/components/prism-{apacheconf,bsash,css,diff,ini,json,nginx,php,sass,scss,sql,less,twig,xml,yaml}.js',
], 'post.js')
});
gulp.task('watch', ['default'], function () {
plugins.refresh.listen();
gulp.watch(config.sass.sourceDir + config.sass.pattern, ['styles']);
gulp.watch(config.js.sourceDir + config.js.pattern, ['scripts']);
});