This repository has been archived by the owner on Dec 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (59 loc) · 1.97 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
65
66
67
68
69
70
//Require packages
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),
rename = require('gulp-rename'),
notify = require('gulp-notify'),
uglify = require('gulp-uglify');
sass.compiler = require('node-sass');
//SCSS -> CSS
//Compile SCSS and save compiled + minified CSS file to 'dist' folder
gulp.task('scssDist', function () {
return gulp.src('src/scss/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer('last 5 version'))
.pipe(gulp.dest('dist'))
.pipe(rename({ suffix: '.min' }))
.pipe(cssnano())
.pipe(gulp.dest('dist'))
.pipe(notify({ message: 'scssDist task complete' }));
});
//Save a copy of compiled CSS in 'docs' folder
gulp.task('scssDocs', function () {
return gulp.src('src/scss/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer('last 5 version'))
.pipe(gulp.dest('docs'))
.pipe(rename({ suffix: '.min' }))
.pipe(notify({ message: 'scssDocs task complete' }));
});
//JS -> JS + MIN.JS
//Put a copy and a minified version of JS file in 'dist' folder
gulp.task('jsDist', function () {
gulp.src('src/js/*.js')
.pipe(gulp.dest('dist'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('dist'))
.pipe(notify({ message: 'jsDist task complete' }));
});
//Put a copy of JS file in 'docs' folder
gulp.task('jsDocs', function () {
gulp.src('src/js/*.js')
.pipe(gulp.dest('docs'))
.pipe(notify({ message: 'jsDocs task complete' }));
});
//HTML -> HTML
//Put a copy of HTML file to 'dist' folder
gulp.task('htmlDist', function () {
gulp.src('src/html/*.html')
.pipe(gulp.dest('dist'))
.pipe(notify({ message: 'htmlDist task complete' }));
});
//WATCH TASKS
gulp.task('watchAll', function () {
gulp.watch('src/js/*.js', ['jsDist', 'jsDocs']);
gulp.watch('src/scss/**/*.scss', ['scssDist', 'scssDocs']);
gulp.watch('src/html/*.html', ['htmlDist']);
});