-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
85 lines (81 loc) · 2.35 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
const gulp = require('gulp');
const path = require('path');
const concat = require("gulp-concat");
const gutil = require('gulp-util');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const rename = require("gulp-rename");
const livereload = require('gulp-livereload');
const less = require('gulp-less');
const pkg = require('./package.json');
const banner = require('gulp-banner');
var comment = '/*\n' +
' * <%= pkg.name %> <%= pkg.version %>\n' +
' * <%= pkg.description %>\n' +
' * <%= pkg.homepage %>\n' +
' *\n' +
' * Copyright 2015, <%= pkg.author %>\n' +
' * Released under the <%= pkg.license %> license.\n' +
'*/\n\n';
gulp.task('js', function () {
let babel_pipe = babel({
presets: ['es2015'],
minified: true,
});
babel_pipe.on('error', function (e) {
gutil.log(e);
babel_pipe.end();
});
return gulp.src(['jquery.imgexplode.js'])
.pipe(babel_pipe)
.pipe(rename(function (path) {
path.basename += ".min";
}))
.pipe(uglify())
.pipe(banner(comment, {
pkg
}))
.pipe(gulp.dest('dist'))
.pipe(livereload())
});
gulp.task('playground-less', function () {
let less = require('gulp-less');
var e = less({});
e.on('error', function (ee) {
gutil.log(ee);
this.emit('end');
});
return gulp.src('playground/less/*')
.pipe(e)
.pipe(gulp.dest("playground/css"))
.pipe(livereload())
});
gulp.task('playground-js', function () {
let babel_pipe = babel({
presets: ['es2015'],
});
babel_pipe.on('error', function (e) {
gutil.log(e);
babel_pipe.end();
});
return gulp.src(['playground/js/*'])
.pipe(babel_pipe)
.pipe(gulp.dest('playground/dist'))
.pipe(livereload())
});
gulp.task('playground', function () {
return gulp.start(["js", "playground-js", "playground-less"]);
});
gulp.task('default', function () {
return gulp.start(["js", 'playground'])
});
gulp.task('reload', function () {
gulp.src("")
.pipe(livereload());
});
livereload.listen();
gulp.watch('./*.js', ['js']);
gulp.watch('index.html', ['reload']);
gulp.watch('playground/js/*', ['playground-js']);
gulp.watch('playground/less/*', ['playground-less']);
gulp.watch('playground.html', ['reload']);