forked from rlamana/ventus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
97 lines (82 loc) · 2.74 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
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
amdOptimize = require("amd-optimize"),
concat = require('gulp-concat'),
wrap = require('gulp-wrap'),
less = require('gulp-less'),
autoprefix = require('gulp-autoprefixer'),
handlebars = require('gulp-handlebars'),
declare = require('gulp-declare'),
defineModule = require('gulp-define-module'),
clean = require('gulp-clean'),
mochaPhantomJS = require('gulp-mocha-phantomjs');
var paths = {
build: 'dist',
source: 'src',
vendor: 'vendor'
};
var package = require('./package.json'),
jshintConfig = require('./jshint.json');
gulp.task('compile:dev', function() {
return gulp.src([
paths.vendor + '/almond',
paths.vendor + '/handlerbars',
paths.vendor + '/underscore',
paths.source + '/**/*.js'
])
.pipe(jshint(jshintConfig))
.pipe(jshint.reporter('default'))
.pipe(amdOptimize(paths.source + '/main', {
paths: {
'almond': paths.vendor + '/almond',
'underscore': paths.vendor + '/underscore',
'handlebars': paths.vendor + '/handlebars',
'$': 'empty:'
}
}))
.pipe(concat(package.name.toLowerCase() + '.js'))
.pipe(wrap({
src: paths.source + '/lib.template'
}))
.pipe(gulp.dest(paths.build));
});
gulp.task('compile:prod', ['compile:dev'], function() {
return gulp.src(paths.build + '/' + package.name.toLowerCase() + '.js')
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(concat(package.name.toLowerCase() + '.min.js'))
.pipe(gulp.dest(paths.build));
});
gulp.task('compile', ['compile:prod']);
gulp.task('less', function () {
gulp.src(paths.source + '/**/*.less')
.pipe(less())
.pipe(autoprefix('last 2 version', 'ie 9'))
.pipe(concat(package.name.toLowerCase() + '.css'))
.pipe(gulp.dest(paths.build));
});
gulp.task('templates', function(){
gulp.src(paths.source + '/**/*.hbs')
.pipe(handlebars())
.pipe(defineModule('amd'))
.pipe(gulp.dest(paths.source));
});
gulp.task('watch', ['default'], function() {
gulp.watch([
paths.source + '/**/*.js',
paths.source + '/lib.template'
], ['compile']);
gulp.watch(paths.source + '/**/*.less', ['less']);
gulp.watch(paths.source + '/**/*.hbs', ['templates', 'compile']);
});
gulp.task('clean', function () {
gulp.src(paths.build, { read: false })
.pipe(clean());
});
gulp.task('test', ['compile'], function() {
gulp.src('test/run.html')
.pipe(mochaPhantomJS());
});
gulp.task('default', ['less', 'templates', 'compile']);