-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
68 lines (52 loc) · 1.65 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
// Load plugins
var gulp = require('gulp'),
babel = require('gulp-babel'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
watch = require('gulp-watch'),
notify = require('gulp-notify'),
sass = require('gulp-sass'),
cleanCSS = require('gulp-clean-css'),
rename = require('gulp-rename'),
sequence = require('gulp-sequence'),
prefix = require('gulp-autoprefixer');
const dist = './dist';
// JS [Lint JS]
gulp.task('lint', () => {
return gulp.src(['./src/js/functions.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(notify({ message: 'JSHint Complete' }));
});
// JS [Concat JS to functions.min.js]
gulp.task('scripts', () => {
return gulp.src([
'./src/js/functions.js'
])
.pipe(babel({presets: ['es2015']}))
.pipe(concat('functions.js'))
.pipe(gulp.dest( dist +'/js/'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest( dist +'/js/'))
.pipe(notify({ message: 'Scripts Task Complete' }));
});
// Sass [Compile]
gulp.task('sass', () => {
gulp.src('./src/scss/screen.scss')
.pipe(sass())
.pipe(prefix({browsers: ['last 2 versions', 'ie >= 9', 'and_chr >= 2.3']}))
.pipe(gulp.dest( dist +'/css/'))
.pipe(cleanCSS())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest( dist +'/css/'))
.pipe(notify({ message: 'Sass Task Complete' }));
});
gulp.task('watch', function() {
gulp.watch('src/js/**/*.js', ['lint', 'scripts']);
gulp.watch('src/scss/**/*.scss', ['sass']);
});
// RUN TASKS
// Default task [Watches all scss and .js changes]
gulp.task('default', ['sass', 'lint', 'scripts', 'watch']);