forked from pixelunion/validetta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
68 lines (55 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
var fs = require('fs');
var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var strip = require('gulp-remove-code');
var header = require('gulp-header');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var del = require('del');
var buildDir = 'dist';
var banner = '/*!\n' +
' * Validetta (<%= pkg.homepage %>)\n' +
' * Version <%= pkg.version %>\n' +
' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
' * Copyright 2013-<%= new Date().getFullYear() %> <%= pkg.author.name %> - <%= pkg.author.url %> \n' +
' */\n';
/* Development tasks */
gulp.task('sass', function() {
return sass('demo/scss/styles.scss')
.pipe(gulp.dest('demo/css'))
.pipe(reload({ stream:true }));
});
gulp.task('js-watch', ['concat'], reload);
gulp.task('serve', ['sass'], function() {
browserSync({
server: {
baseDir: ['demo', 'dist'],
},
});
gulp.watch('demo/scss/*.scss', ['sass']);
gulp.watch('src/validetta.js', ['js-watch']);
gulp.watch(['demo/index.html', 'demo/js/main.js']).on('change', reload);
});
/* Build tasks */
gulp.task('clean', function() {
return del(buildDir + '/*');
});
gulp.task('concat', function() {
gulp.src('src/validetta.js')
.pipe(strip({commentStart: '/*!', commentEnd: '*/'}))
.pipe(header(banner, { pkg : pkg}))
.pipe(gulp.dest('dist'));
});
gulp.task('uglify', function() {
return gulp.src('src/validetta.js')
.pipe(uglify())
.pipe(header(banner, { pkg : pkg}))
.pipe(rename({
extname: '.min.js',
}))
.pipe(gulp.dest('dist'));
});
gulp.task('build', ['clean', 'concat', 'uglify']);