This repository has been archived by the owner on Aug 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
gulpfile.js
73 lines (63 loc) · 1.66 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
'use strict';
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var open = require('gulp-open');
var connect = require('gulp-connect');
var cleanCSS = require('gulp-clean-css');
var open = require('gulp-open');
function isArray (arr) {
return typeof path == 'object' && path.hasOwnProperty('length');
}
function genFile (path, filename, shouldUglify, dist) {
var fileList = [];
if (isArray(path)) {
fileList = path;
} else {
fileList.push(path);
}
var file = gulp.src(fileList);
if (shouldUglify) {
file
.pipe(concat(filename.replace('.js', '.min.js')))
.pipe(uglify())
.pipe(gulp.dest(dist));
}
file
.pipe(concat(filename))
.pipe(gulp.dest(dist));
}
gulp.task('dev', function () {
gulp
.src(['./src/angular-json-explorer.js', './src/angular-json-explorer.css'])
.pipe(gulp.dest('./dist'))
.pipe(connect.reload({port: 5000}));
});
gulp.task('dist', function () {
gulp
.src('./src/angular-json-explorer.js')
.pipe(uglify())
.pipe(concat('angular-json-explorer.min.js'))
.pipe(gulp.dest('./dist'));
gulp
.src('./src/angular-json-explorer.css')
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(concat('angular-json-explorer.min.css'))
.pipe(gulp.dest('./dist'));
});
gulp.task('watch', function () {
gulp.watch('./src/**/*', ['dev', 'dist']);
});
gulp.task('run', function () {
connect.server({
root: ['demo', 'dist'],
port: 5000,
livereload: true
});
});
gulp.task('open', function () {
gulp
.src(__filename)
.pipe(open({uri: 'http://127.0.0.1:5000'}));
});
gulp.task('default', ['dev', 'run', 'watch', 'open']);