-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
85 lines (74 loc) · 2.23 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"use strict";
var gulp = require('gulp'),
gutil = require('gulp-util'),
jshint = require('gulp-jshint'),
rimraf = require('gulp-rimraf'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
cleanCSS = require('gulp-clean-css'),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('gulp-autoprefixer'),
runSequence = require('run-sequence'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
packageJSON = require('./package'),
gulpif = require('gulp-if');
const isDev = !process.env.NODE_ENV || process.env.NODE_ENV == "development";
var path = {
js: 'src/**/*.js',
css: 'src/**/*.css',
dist: 'dist/'
};
gulp.task('css', function(){
return gulp.src(path.css)
.pipe(autoprefixer())
.pipe(gulp.dest(path.dist))
.pipe(cleanCSS())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(path.dist));
});
gulp.task('jslint', function(){
return gulp.src(path.js)
.pipe(jshint(packageJSON.jshintConfig))
.pipe(jshint.reporter('jshint-stylish'))
//.pipe(jshint.reporter('fail'))
});
var jsMainPath = "src/jquery.humanpicker.js",
jsDestName = "jquery.humanpicker.js";
var brOpts = {
entries: [jsMainPath],
debug: isDev // gen sourcemaps
};
var b = browserify(brOpts);
gulp.task('js', ['jslint'], function(){
return b.bundle()
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source(jsDestName))
.pipe(gulp.dest(path.dist))
.pipe(buffer())
.pipe(gulpif(isDev, sourcemaps.init({loadMaps: true})))
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulpif(isDev, sourcemaps.write()))
.pipe(gulp.dest(path.dist));
});
gulp.task('watch', function(){
gulp.watch(path.css, ['css']);
gulp.watch(path.js, ['js']);
});
gulp.task('clean', function(){
return gulp.src(path.dist+'**/*.*', { read: false })
.pipe(rimraf());
});
gulp.task('build', function(cb) {
runSequence('clean', ['css', 'js'], function(){
gutil.log(gutil.colors.green('Successfull build'));
cb();
});
});
gulp.task('default', ["build"]);