-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
115 lines (99 loc) · 3.43 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
* @author Bilal Cinarli
*/
"use strict";
var gulp = require("gulp"),
pkg = require('./package.json'),
isTravis = process.env.TRAVIS || false,
// utils
header = require("gulp-header"),
notify = require("gulp-notify"),
rename = require("gulp-rename"),
sourcemaps = require("gulp-sourcemaps"),
uglify = require("gulp-uglify"),
// sass
sass = require("gulp-sass"),
autoprefixer = require("gulp-autoprefixer"),
// lint
jshint = require("gulp-jshint"),
csslint = require("gulp-csslint"),
// testing
mochaPhantomJs = require('gulp-mocha-phantomjs');
var paths = {
lib : 'lib/',
dist : 'dist/',
test : 'test/',
examples: 'examples/'
};
var banner = [
"/*! UX Rocket Autocomplete \n" +
" * <%= pkg.description %> \n" +
" * @author <%= pkg.author %> \n" +
"<% pkg.contributors.forEach(function(contributor) { %>" +
" * <%= contributor.name %> <<%=contributor.email %>> (<%=contributor.url %>)\n" +
"<% }) %>" +
" * @version <%= pkg.version %> \n" +
" * @build <%= date %> \n" +
" */\n"
].join('');
var tasks = {
mocha: function() {
return gulp.src(paths.test + 'index.html')
.pipe(mochaPhantomJs());
},
sass: function() {
return gulp.src(paths.lib + "**/*.scss")
.pipe(sourcemaps.init())
.pipe(sass({
outputStyle: "expanded"
}))
.pipe(autoprefixer({
browsers: ['last 5 versions']
}))
.pipe(rename('uxrocket.autocomplete.css'))
.pipe(gulp.dest(paths.dist))
.pipe(sass({
outputStyle: "compressed"
})).on("error", notify.onError("Error: <%= error.message %>"))
.pipe(autoprefixer({
browsers: ['last 5 versions']
}))
.pipe(rename('uxrocket.autocomplete.min.css'))
.pipe(header(banner, {pkg: pkg, date: new Date()}))
.pipe(sourcemaps.write('./'))
.pipe(notify('Sass styles completed'))
.pipe(gulp.dest(paths.dist));
},
csslint: function() {
return gulp.src(paths.dist + "uxrocket.autocomplete.css")
.pipe(csslint())
.pipe(csslint.reporter());
},
lint: function() {
return gulp.src(paths.lib + "**/*.js")
.pipe(jshint()).on("error", notify.onError("Error: <%= error.message %>"))
.pipe(jshint.reporter("default"))
.pipe(notify('JSHint completed'));
},
scripts: function() {
return gulp.src(paths.lib + "**/*.js")
.pipe(rename('uxrocket.autocomplete.js'))
.pipe(gulp.dest(paths.dist))
.pipe(uglify()).on("error", notify.onError("Error: <%= error.message %>"))
.pipe(header(banner, {pkg: pkg, date: new Date()}))
.pipe(rename('uxrocket.autocomplete.min.js'))
.pipe(notify('Script file uglified'))
.pipe(gulp.dest(paths.dist));
}
};
gulp.task('sass', tasks.sass);
gulp.task('csslint', tasks.csslint);
gulp.task('lint', tasks.lint);
gulp.task('scripts', tasks.scripts);
gulp.task('mocha', tasks.mocha);
gulp.task('watch', ['csslint', 'sass', 'lint', 'scripts', 'mocha'], function() {
gulp.watch(paths.lib + '**/*.scss', ['sass']);
gulp.watch(paths.dist + '**/*.css', ['csslint']);
gulp.watch(paths.lib + '**/*.js', ['lint', 'scripts', 'mocha']);
});
gulp.task('default', ['watch']);