-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
64 lines (57 loc) · 1.79 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')();
var autoprefixer = require('autoprefixer-core');
// start server via express
gulp.task('server', function() {
var app = require('./app/app');
app;
});
// optimize images
gulp.task('images', function() {
return gulp.src('./public/images/*')
.pipe(plugins.plumber())
.pipe(plugins.cache(plugins.imagemin({
interlaced: true,
optimizationLevel: 5,
progressive: true
})))
.pipe(gulp.dest('./assets/images'))
});
// concatenate and uglify scripts
gulp.task('scripts', function() {
return gulp.src('./public/scripts/author/*.js')
.pipe(plugins.plumber())
.pipe(plugins.concat('all.js'))
.pipe(plugins.uglify())
.pipe(plugins.rename({suffix: '.min'}))
.pipe(gulp.dest('./public/scripts/'))
});
// compile and minify sass
gulp.task('styles', function() {
var processors = [
autoprefixer(['last 6 version'])
];
return plugins.rubySass(
'./public/styles/', {
require: ['breakpoint', 'susy'],
sourcemap: true,
style: 'compressed'
})
.on("error", plugins.notify.onError({
message: "Error: <%= error.message %>",
title: "Error running something"
}))
.pipe(plugins.postcss(processors))
.pipe(plugins.rename({suffix: '.min'}))
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest('./public/styles/'))
});
gulp.task('watch', function(){
gulp.watch('./public/images/**/*', ['images']);
gulp.watch('./public/styles/**/*.scss', ['styles']);
gulp.watch('./public/scripts/author/**/*.js', ['scripts']);
plugins.livereload.listen();
gulp.watch(['./app/**', './public/**']).on('change', plugins.livereload.changed);
});
// default task: handle assets, start server, watch & reload
gulp.task('default', ['images', 'scripts', 'styles', 'server', 'watch']);