Tidy gulpfile

This commit is contained in:
Oliver Davies 2017-01-26 19:20:21 +00:00
parent 546cf208fc
commit 7f4a36f906

View file

@ -6,10 +6,12 @@ var del = require('del');
var config = require('./gulpfile.config')(plugins);
var app = {};
app.sass = function(paths, filename) {
return gulp.src(paths)
gulp.task('styles', function() {
return gulp.src([
config.bower.path + '/font-awesome/css/font-awesome.css',
config.bower.path + '/highlightjs/styles/default.css',
config.sass.source + config.sass.pattern
])
.pipe(plugins.plumber())
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
.pipe(plugins.sassGlob())
@ -18,27 +20,32 @@ app.sass = function(paths, filename) {
browsers: config.autoprefixer.browsers,
cascade: false
}))
.pipe(plugins.concat(filename))
.pipe(plugins.concat('site.css'))
.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.destination));
};
});
app.js = function(paths, filename) {
return gulp.src(paths)
gulp.task('scripts', function() {
return gulp.src([
config.bower.path + '/jquery2/jquery.js',
config.bower.path + '/bootstrap-sass/assets/javascripts/bootstrap.js',
config.bower.path + '/highlightjs/highlight.pack.js',
config.js.source + config.js.pattern
])
.pipe(plugins.plumber())
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
.pipe(plugins.concat(filename))
.pipe(plugins.concat('site.js'))
.pipe(plugins.if(config.production, plugins.uglify()))
.pipe(plugins.if(!config.production, plugins.sourcemaps.write('.')))
.pipe(gulp.dest(config.js.destination));
};
});
app.copy = function(source, destination) {
return gulp.src(source)
.pipe(gulp.dest(destination));
};
gulp.task('fonts', function() {
return gulp.src(config.bower.path + "/font-awesome/fonts/*")
.pipe(gulp.dest(config.fonts.destination));
});
gulp.task('clean', function() {
del.sync(config.fonts.destination);
@ -49,30 +56,6 @@ gulp.task('clean', function() {
del.sync('output_*/assets/js');
});
gulp.task('fonts', function() {
return app.copy(
config.bower.path + "/font-awesome/fonts/*",
config.fonts.destination
);
});
gulp.task('styles', function() {
return app.sass([
config.bower.path + '/font-awesome/css/font-awesome.css',
config.bower.path + '/highlightjs/styles/default.css',
config.sass.source + config.sass.pattern
], 'site.css');
});
gulp.task('scripts', function() {
return app.js([
config.bower.path + '/jquery2/jquery.js',
config.bower.path + '/bootstrap-sass/assets/javascripts/bootstrap.js',
config.bower.path + '/highlightjs/highlight.pack.js',
config.js.source + config.js.pattern
], 'site.js');
});
gulp.task('default', ['clean', 'fonts', 'styles', 'scripts']);
gulp.task('watch', ['default'], function() {