-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (54 loc) · 1.56 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
const gulp = require('gulp');
const imagemin = require('gulp-imagemin');
const uglify = require('gulp-uglify');
const sass = require('gulp-sass');
// TOP LEVEL FUNCTIONS
// gulp.task - Define a task
// gulp.src - Point to the files to use
// gulp.dest - Points to the folder to output
// gulp.watch - Watch files and folders for changes
//logs message
gulp.task('message', function(){
return console.log("Gulp is running...");
});
//Copy all HTML files
gulp.task('copyHtml', function(){
gulp.src('src/*.html')
.pipe(gulp.dest('dist'));
});
//Copy Assets
gulp.task('copyAss', function(){
gulp.src('src/assets/fonts/*')
.pipe(gulp.dest('dist/assets/fonts'));
});
//optimize images
gulp.task('imageMin', function(){
gulp.src('src/images/*')
.pipe(imagemin())
.pipe(gulp.dest('dist/images'))
});
// gulp.task('imageMin', () =>
// gulp.src('src/images/*')
// .pipe(imagemin())
// .pipe(gulp.dest('dist/images'))
// );
//Minify JS
gulp.task('minify', function(){
gulp.src('src/*.js')
.pipe(uglify())
.pipe(gulp.dest('dist/js'))
});
//Compile Sass
gulp.task('sass', function(){
gulp.src('src/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('dist/css'))
});
gulp.task('default', ['message', 'copyHtml','copyAss', 'imageMin', 'minify', 'sass']);
gulp.task('watch', function(){
gulp.watch('src/*.html', ['copyHtml']);
gulp.watch('src/assets/fonts/*', ['copyAss']);
gulp.watch('src/images/*', ['imageMin']);
gulp.watch('src/*.js', ['minify']);
gulp.watch('src/*.scss', ['sass']);
});