-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
44 lines (38 loc) · 1.27 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
'use strict';
var argv = require('yargs').argv;
var gulp = require('gulp');
var gutil = require('gulp-util');
var gulpif = require('gulp-if');
var sass = require('gulp-sass');
var eslint = require('gulp-eslint');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
gulp.task('default', ['sass', 'lint', 'uglify', 'watch']);
gulp.task('sass', function() {
return gulp.src('./src/jquery.imgplay.scss')
.pipe(sass({outputStyle: (argv.production ? 'compressed' : 'nested')}).on('error', sass.logError))
.pipe(gulp.dest('./dist'));
});
gulp.task('uglify', function() {
return gulp.src('./src/jquery.imgplay.js')
.pipe(gulpif(argv.production, uglify()))
.pipe(gulpif(argv.production, rename({suffix: '.min'})))
.pipe(gulp.dest('./dist'));
});
gulp.task('lint', function() {
return gulp.src('./src/jquery.imgplay.js')
.pipe(eslint({
'rules': {
'quotes': [1, 'single'],
'semi': [1, 'always']
}
}))
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
gulp.task('watch', function() {
if(!argv.production) {
gulp.watch('./src/jquery.imgplay.scss', ['sass']);
gulp.watch('./src/jquery.imgplay.js', ['lint']);
}
});