forked from feimosi/baguetteBox.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
152 lines (128 loc) · 3.89 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/* jshint node:true */
'use strict';
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')(),
browserSync = require('browser-sync'),
jsonfile = require('jsonfile'),
runSequence = require('run-sequence');
var src = {
css: ['./src/*.scss', './src/*.css'],
js: './src/*.js'
};
var demo = {
allFiles: './demo/**/*',
css: './demo/css/',
js: './demo/js/',
html: './demo/',
base: './demo/'
};
var dist = {
css: './dist/',
js: './dist/'
};
var autoprefixerBrowsers = [
'last 2 version',
'> 1%',
'Edge >= 12',
'Explorer >= 8',
'Firefox 3.6',
'Firefox ESR',
'Opera 12.1'
];
gulp.task('build.demo-css', function() {
return gulp.src(src.css)
.pipe(plugins.if(/.scss/, plugins.sass({ style: 'compressed', noCache: true }))) // jshint ignore:line
.pipe(plugins.autoprefixer(autoprefixerBrowsers))
.pipe(plugins.concat('baguetteBox.css'))
.pipe(gulp.dest(demo.css));
});
gulp.task('build.demo-js', function () {
return gulp.src(src.js)
.pipe(plugins.concat('baguetteBox.js'))
.pipe(gulp.dest(demo.js));
});
gulp.task('build.dist-css', function() {
return gulp.src(src.css)
.pipe(plugins.if(/.scss/, plugins.sass({ style: 'compressed', noCache: true }))) // jshint ignore:line
.pipe(plugins.autoprefixer(autoprefixerBrowsers))
.pipe(plugins.concat('baguetteBox.css'))
.pipe(gulp.dest(dist.css))
.pipe(plugins.concat('baguetteBox.min.css'))
.pipe(plugins.cssmin())
.pipe(gulp.dest(dist.css));
});
gulp.task('build.dist-js', function() {
return gulp.src(src.js)
.pipe(plugins.concat('baguetteBox.js'))
.pipe(gulp.dest(dist.js))
.pipe(plugins.concat('baguetteBox.min.js'))
.pipe(plugins.uglify({ preserveComments: 'some' }))
.pipe(gulp.dest(dist.js));
});
gulp.task('build.demo', ['build.demo-css', 'build.demo-js']);
gulp.task('build.dist', ['build.dist-css', 'build.dist-js']);
gulp.task('lint', function() {
return gulp.src([src.js, 'gulpfile.js'])
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('jshint-stylish'))
.pipe(plugins.jshint.reporter('fail'));
});
gulp.task('bump-minor', function () {
return gulp.src(['./bower.json', './package.json'])
.pipe(plugins.bump({ type: 'minor' }))
.pipe(gulp.dest('./'));
});
gulp.task('bump-patch', function () {
return gulp.src(['./bower.json', './package.json'])
.pipe(plugins.bump({ type: 'patch' }))
.pipe(gulp.dest('./'));
});
gulp.task('update-version', function () {
return gulp.src([demo.css + '*.css',
demo.js + '*.js',
dist.css + '*.css',
dist.js + '*.js'
], {
base: './'
})
.pipe(plugins.injectVersion({
replace: '%%INJECT_VERSION%%',
prepend: ''
}))
.pipe(gulp.dest('./'));
});
gulp.task('watch', ['watch.browser-sync'], function() {
gulp.watch(src.css, ['build.demo-css']);
gulp.watch(src.js, ['build.demo-js', 'lint']);
});
gulp.task('watch.browser-sync', ['build.demo'], function () {
var files = [
demo.html + '*.html',
demo.css + '*.css',
demo.js + '*.js'
];
browserSync.init(files, {
server: {
baseDir: demo.base
}
});
});
gulp.task('deploy', function() {
var packageJson = jsonfile.readFileSync('./package.json');
return gulp.src(demo.allFiles)
.pipe(plugins.ghPages({
push: false,
message: 'v' + packageJson.version
}));
});
gulp.task('release', function() {
runSequence('bump-minor', 'build');
});
gulp.task('patch', function() {
runSequence('bump-patch', 'build');
});
gulp.task('build', function() {
runSequence(['build.demo', 'build.dist'], 'update-version');
});
gulp.task('test', ['build', 'lint']);
gulp.task('default', ['watch']);