-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
63 lines (55 loc) · 1.53 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
var gulp = require('gulp')
var concat = require('gulp-concat')
var uglify = require('gulp-uglify')
var rename = require('gulp-rename')
var minifyCSS = require('gulp-minify-css')
var postcss = require('gulp-postcss')
var sourcemaps = require('gulp-sourcemaps')
var autoprefixer = require('autoprefixer')
var browserify = require('browserify')
var source = require('vinyl-source-stream')
var buffer = require('vinyl-buffer')
var paths = {
root: './',
index: './index.html',
src: {
css: './src/css/*css',
js: './src/js/*.js',
jsIndex: './src/js/index.js',
jsMain: './src/js/material-photo-gallery.js'
},
dist: {
css: './dist/css',
js: './dist/js',
bundle: './dist/js/bundle.js'
}
}
gulp.task('watch', ['css', 'browserify'], function() {
gulp.watch(paths.src.css, ['css'])
gulp.watch(paths.src.js, ['browserify'])
})
gulp.task('css', function() {
return gulp
.src(paths.src.css)
.on('error', handleError)
.pipe(postcss([autoprefixer()]))
.pipe(minifyCSS())
.pipe(gulp.dest(paths.dist.css))
})
gulp.task('browserify', function() {
return browserify(paths.src.jsIndex)
.bundle()
.on('error', handleError)
.pipe(source('material-photo-gallery.js'))
.pipe(buffer())
.pipe(gulp.dest(paths.dist.js))
.pipe(uglify())
.pipe(rename('material-photo-gallery.min.js'))
.pipe(gulp.dest(paths.dist.js))
})
// Handle errors and continue watching files
function handleError(err) {
console.log(err.toString())
this.emit('end')
}
gulp.task('default', ['css', 'browserify'])