-
Notifications
You must be signed in to change notification settings - Fork 48
/
gulpfile.js
155 lines (124 loc) · 3.96 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
'use strict';
// generated on 2015-04-04 using generator-gulp-webapp 0.1.0
var gulp = require('gulp');
// load plugins
var $ = require('gulp-load-plugins')();
const babel = require('gulp-babel');
gulp.task('scripts', function () {
return gulp.src('src/**/*.js')
.pipe(babel({
presets: ['es2015'],
plugins: ["array-includes", "transform-object-rest-spread"]
}))
.pipe($.jshint())
.pipe($.jshint.reporter(require('jshint-stylish')))
.pipe($.size());
});
gulp.task('compile-to-es5', function () {
return gulp.src('src/**/*.js')
.pipe(babel({
presets: ['es2015'],
plugins: ["array-includes", "transform-object-rest-spread"]
}))
.pipe(gulp.dest('dist'))
.pipe($.size());
});
var rename = require('gulp-rename');
gulp.task('js', ['scripts', 'compile-to-es5'], function () {
var jsFilter = $.filter('**/*.js', {restore: true});
return gulp.src('src/**/*.js')
.pipe(babel({
presets: ['es2015'],
plugins: ["array-includes", "transform-object-rest-spread"]
}))
.pipe($.uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist'))
.pipe($.size());
});
gulp.task('clean', function () {
return gulp.src(['.tmp', 'dist'], { read: false }).pipe($.clean());
});
gulp.task('build', ['js', 'copy-js', 'main-bower-files'], function(){
return gulp.src('./bower_components/isotope/dist/isotope.pkgd.js')
.pipe(gulp.dest('./examples/libs/isotope'))
});
gulp.task('default', ['clean'], function () {
gulp.start('build');
});
gulp.task('connect', function () {
var connect = require('connect');
var serveStatic = require('serve-static');
var serveIndex = require('serve-index');
var app = connect()
.use(require('connect-livereload')({ port: 35729 }))
.use(serveStatic('.tmp'))
.use(serveStatic('examples'))
.use(serveIndex('examples'));
require('http').createServer(app)
.listen(9000)
.on('listening', function () {
console.log('Started connect web server on http://localhost:9000');
});
});
gulp.task('serve', ['connect'], function () {
require('opn')('http://localhost:9000');
});
var mainBowerFiles = require('gulp-main-bower-files');
gulp.task('main-bower-files', function() {
return gulp.src('./bower.json')
.pipe(mainBowerFiles({
includeDev:true,
overrides: {
"isotope-packery": {
main: "packery-mode.pkgd.js"
},
vue: {
main: './dist/vue.js'
}
}
}))
.pipe(gulp.dest('./examples/libs'));
});
gulp.task('copy-js', function() {
return gulp.src('src/**/*.js')
.pipe(babel({
presets: ['es2015'],
plugins: ["array-includes", "transform-object-rest-spread"]
}))
.pipe(gulp.dest('./examples/src'));
});
var jip = require('jasmine-istanbul-phantom');
var changedSpec = null
gulp.task('test', function(done) {
var options = { callback: done, lib : ['bower_components/**/*.js'] }
if (changedSpec)
options.spec = changedSpec
jip(options)
changedSpec = null
});
gulp.task('watch', ['connect', 'serve'], function () {
var server = $.livereload;
server.listen();
// watch for changes
gulp.watch([
'examples/*.html',
'src/**/*.js',
'examples/*.css',
'examples/**/*.js',
]).on('change', server.changed);
gulp.watch('./bower.json').on('change', function() {
gulp.start('main-bower-files')
});
gulp.watch('src/**/*.js', ['scripts']);
gulp.watch('src/**/*.js').on('change', function() {
gulp.start('copy-js');
gulp.start('test');
});
// gulp.watch('test/spec/*.js').on('change', function(event){
// changedSpec = event.path
// gulp.start('test')
// });
});