-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgulpfile.js
executable file
·47 lines (42 loc) · 1.42 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
var gulp = require('gulp'),
plumber = require('gulp-plumber');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var imagemin = require('gulp-imagemin'),
cache = require('gulp-cache');
var sass = require('gulp-sass');
gulp.task('images', () => {
return gulp.src('src/images/**/*')
.pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))
.pipe(gulp.dest('dist/images/'));
});
gulp.task('styles', () => {
return gulp.src(['src/styles/**/*.scss'])
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(sass({
outputStyle: 'compressed',
includePaths: ['node_modules/foundation-sites/scss'] // include path to foundation in node modules
}))
.pipe(autoprefixer('last 2 versions'))
.pipe(gulp.dest('dist/styles/'))
});
gulp.task('scripts', () => {
return gulp.src('src/scripts/**/*.js')
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(concat('main.js'))
.pipe(gulp.dest('dist/scripts/'))
});
gulp.task('watch', () => {
gulp.watch('src/styles/**/*.scss', gulp.series('styles'));
gulp.watch('src/scripts/**/*.js', gulp.series('scripts'));
gulp.watch('src/images/**', gulp.series('images'));
});
gulp.task('default', gulp.parallel('styles', 'scripts', 'images'));