-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
69 lines (62 loc) · 1.79 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
var gulp = require('gulp');
var gutil = require('gulp-util');
var coffeelint = require('gulp-coffeelint');
var coffee = require('gulp-coffee');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var less = require('gulp-less');
var header = require('gulp-header');
var clean = require('gulp-clean');
var open = require('gulp-open');
var pkg = require('./package.json');
var name = pkg.name;
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
gulp.task('coffee', function() {
gulp.src('src/' + name + '.coffee')
.pipe(coffeelint({
indentation: 2,
no_trailing_semicolons: true,
no_trailing_whitespace: true
}))
.pipe(coffee()).on('error', gutil.log)
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest('dist'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest('dist'));
});
gulp.task('less', function() {
gulp.src('src/' + name + '.less')
.pipe(less())
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest('dist'))
.pipe(rename({ suffix: '.min' }))
.pipe(less({
compress: true,
cleancss: true
}))
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest('dist'));
});
gulp.task('clean', function(done) {
gulp.src('dist', { read: false })
.pipe(clean())
.on('end', done);
});
gulp.task("open", function() {
gulp.src("index.html")
.pipe(open());
});
gulp.task('watch', function () {
gulp.watch('src/' + name + '.coffee', ['coffee'])
gulp.watch('src/' + name + '.less', ['less']);
});
gulp.task('dist', ['clean', 'coffee', 'less']);
gulp.task('default', ['dist', 'open', 'watch']);