-
Notifications
You must be signed in to change notification settings - Fork 70
/
gulpfile.js
76 lines (68 loc) · 2.02 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
var gulp = require('gulp'),
fs = require('fs'),
header = require('gulp-header'),
coffee = require('gulp-coffee'),
replace = require('gulp-replace'),
uglify = require('gulp-uglify'),
coffeelint = require('gulp-coffeelint'),
minifyCSS = require('gulp-minify-css'),
rename = require('gulp-rename'),
gutil = require('gulp-util');
var path = {
coffee: 'src/coffee/BttrLazyLoading.coffee',
copyright: 'copyright',
version: 'version',
css: 'src/css/bttrlazyloading.css',
build: 'dist/'
};
var name = {
js: 'jquery.bttrlazyloading.js',
jsmin: 'jquery.bttrlazyloading.min.js',
css: 'bttrlazyloading.css',
cssmin: 'bttrlazyloading.min.css'
};
var getVersion = function() {
return fs.readFileSync(path.version);
};
var getCopyright = function() {
return fs.readFileSync(path.copyright);
};
gulp.task('default', ['lint', 'coffee', 'css']);
// https://www.npmjs.org/package/gulp-coffeelint
gulp.task('lint', function() {
gulp.src(path.coffee)
.pipe(coffeelint())
.pipe(coffeelint.reporter());
});
// https://www.npmjs.org/package/gulp-coffee
gulp.task('coffee', function() {
return gulp.src(path.coffee)
.pipe(replace('@@version', getVersion()))
.pipe(coffee())
.pipe(rename(name.js))
.pipe(header(getCopyright(), {
version: getVersion()
}))
.pipe(gulp.dest(path.build))
.pipe(uglify())
.pipe(rename(name.jsmin))
.pipe(header(getCopyright(), {
version: getVersion()
}))
.pipe(gulp.dest(path.build));
});
// https://www.npmjs.org/package/gulp-minify-css
gulp.task('css', function() {
return gulp.src(path.css)
.pipe(rename(name.css))
.pipe(header(getCopyright(), {
version: getVersion()
}))
.pipe(gulp.dest(path.build))
.pipe(minifyCSS())
.pipe(rename(name.cssmin))
.pipe(header(getCopyright(), {
version: getVersion()
}))
.pipe(gulp.dest(path.build));
});