-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
60 lines (52 loc) · 1.76 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
var gulp = require('gulp');
// Include plugins
var plugins = require('gulp-load-plugins')(); // load all plugins
// CSS
gulp.task('css', function () {
return gulp.src('src/sass/style.scss')
.pipe(plugins.sourcemaps.init())
.pipe(plugins.plumber())
.pipe(plugins.sass().on('error', plugins.sass.logError)) // compile Sass
.pipe(plugins.autoprefixer()) // autoprefix
.pipe(plugins.csso()) // minify
.pipe(plugins.livereload())
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest(''));
});
// JS
gulp.task('js', function() {
return gulp.src('src/js/site.js')
.pipe(plugins.sourcemaps.init())
.pipe(plugins.plumber())
.pipe(plugins.uglify()) // minify
.pipe(plugins.livereload())
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest('static'));
});
// Clean
gulp.task('clean', function() {
return gulp.src('static', {read: false})
.pipe(plugins.clean());
});
// Images optimisation
gulp.task('img', function () {
return gulp.src('src/img/*.{png,jpg,svg}')
.pipe(plugins.imagemin())
.pipe(gulp.dest('static/img'));
});
// Watch
gulp.task('watch', function(){
plugins.livereload.listen(35729);
gulp.watch('**/*.php').on('change', function(file) {
plugins.livereload.changed(file.path);
});
gulp.watch('**/*.twig').on('change', function(file) {
plugins.livereload.changed(file.path);
});
gulp.watch('src/sass/**/*.scss',['css']);
gulp.watch('src/js/site.js',['js']);
});
// Build
gulp.task('build', ['clean', 'css', 'js', 'img']);
// Default
gulp.task('default', ['watch']);