-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
96 lines (84 loc) · 2.32 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
'use strict';
// TODO: Break out base URLs into vars
// TODO: Make paths absolute to the project dir
var browserify = require('browserify'),
gulp = require('gulp'),
watch = require('gulp-watch'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
minify = require('gulp-minify-css'),
sourcemaps = require('gulp-sourcemaps'),
gutil = require('gulp-util'),
gulpPrint = require('gulp-print'),
del = require('del'),
babel = require('gulp-babel');
gulp.task('js', function () {
// set up the browserify instance on a task basis
var b = browserify({
entries: './src/js-gallery-fixed.js',
debug: true
});
return b.bundle()
.pipe(source('js-gallery-fixed.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
// Add transformation tasks to the pipeline here.
.pipe(babel())
.pipe(uglify())
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/js/'));
});
gulp.task('sass', function(){
return gulp.src('./src/js-gallery-fixed.scss')
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sass())
.pipe(minify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/css/'));
});
gulp.task('assets', ['clean-assets'], function(){
return gulp.src([
'./src/index.html',
'./src/assets/**/*'
], { base: './src'})
.pipe(gulp.dest('./dist'));
});
gulp.task('clean-assets', function(){
del('./dist/assets/**/*').then(paths => {
console.log('Cleaned the assets folder');
});
});
gulp.task('clean', ['clean-assets'], function(){
console.log('Cleaned project');
});
gulp.task('build', ['js', 'sass', 'assets'], function(){
return console.log('Resources built...');
});
gulp.task('watch', ['build'], function(){
let watchOptions = {
events: ['add', 'change', 'unlink'],
read: false
}
watch('./src/**/*.js', watchOptions, function(){
gulp.start('js');
});
watch([
'./src/**/*.scss',
'./src/**/*.css'
],
watchOptions,
function(){
gulp.start('sass');
});
watch([
'./src/index.html',
'./src/assets/*'
],
watchOptions,
function(){
gulp.start('assets');
});
})