-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
77 lines (68 loc) · 2.13 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
const gulp = require('gulp');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const uglifycss = require('gulp-uglifycss');
const del = require('del');
const browserSync = require('browser-sync');
const butternut = require('gulp-butternut');
// Lots o' paths
const paths = {
baseName: 'lg-exif',
src: 'src/',
dest: 'dist/',
example: 'example/',
js: {
get src () { return paths.src + 'js/**/*.js' },
get dest () { return paths.dest + 'js/' }
},
css: {
get src() { return paths.src + 'css/**/*.css' },
get dest() { return paths.dest + 'css/' }
}
};
// Concat Tasks
gulp.task('js', () => {
return gulp.src(paths.js.src)
.pipe(concat(paths.baseName + '.js'))
.pipe(gulp.dest(paths.js.dest))
.pipe(browserSync.reload({ stream: true }));
});
gulp.task('css', () => {
return gulp.src(paths.css.src)
.pipe(concat(paths.baseName + '.css'))
.pipe(gulp.dest(paths.css.dest))
.pipe(browserSync.reload({ stream: true }));
});
// Minify Tasks
gulp.task('minify-js', () => {
return gulp.src(paths.js.dest + paths.baseName + '.js')
.pipe(butternut())
.pipe(rename(paths.baseName + '.min.js'))
.pipe(gulp.dest(paths.js.dest));
});
gulp.task('minify-css', () => {
return gulp.src(paths.css.dest + paths.baseName + '.css')
.pipe(uglifycss())
.pipe(rename(paths.baseName + '.min.css'))
.pipe(gulp.dest(paths.css.dest));
});
// Other Tasks
gulp.task('clean', () => {
return del(paths.dest, { force: true });
});
// Meta Tasks
gulp.task('concat', gulp.series('clean', gulp.parallel('js', 'css')));
gulp.task('minify', gulp.parallel(gulp.series('js', 'minify-js'), gulp.series('css', 'minify-css')));
gulp.task('default', gulp.series('minify'));
// Live reload via browser sync
gulp.task('serve', gulp.series('default', () => {
browserSync.init({
server: {
basedir: './'
},
startPath: paths.example,
files: paths.example + '**/*'
});
gulp.watch(paths.js.src, gulp.series('js'));
gulp.watch(paths.css.src, gulp.series('css'));
}));