forked from rnel/jquery-contentshow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (64 loc) · 2 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
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var minifyCss = require('gulp-minify-css');
var browserSync = require('browser-sync');
var del = require('del');
var runSequence = require('run-sequence');
gulp.task('source-js', function() {
gulp.src('src/js/*.js')
// non minified version
.pipe(gulp.dest('dist'))
.pipe(browserSync.stream())
// minified version
.pipe(uglify())
.pipe(rename({ extname: '.min.js'}))
.pipe(gulp.dest('dist'))
.pipe(browserSync.stream());
});
gulp.task('source-sass', function() {
gulp.src('src/sass/*.scss')
.pipe(sass({outputStyle: 'expanded'}).on('error', sass.logError))
// non minified version
.pipe(gulp.dest('dist'))
.pipe(browserSync.stream())
// minified version
.pipe(minifyCss())
.pipe(rename({ extname: '.min.css'}))
.pipe(gulp.dest('dist'))
.pipe(browserSync.stream());
});
gulp.task('demo-sass', function() {
gulp.src('src/demo/sass/*.scss')
.pipe(sass({outputStyle: 'expanded'}).on('error', sass.logError))
.pipe(gulp.dest('dist/demo/css'))
.pipe(browserSync.stream());
});
gulp.task('images', function() {
gulp.src('src/**/*.{jpg,png,gif}')
.pipe(gulp.dest('dist'))
.pipe(browserSync.stream());
});
gulp.task('html', function() {
gulp.src('src/**/*.html')
.pipe(gulp.dest('dist'))
.pipe(browserSync.stream());
});
gulp.task('clean', del.bind(null, ['dist/*'], {dot: true}));
gulp.task('serve', ['source-js', 'source-sass', 'demo-sass', 'html', 'images'], function() {
browserSync({
server: {
baseDir: 'dist'
}
});
gulp.watch('src/js/*.js', ['source-js']);
gulp.watch('src/sass/*.scss', ['source-sass']);
gulp.watch('src/demo/sass/*.scss', ['demo-sass']);
gulp.watch('src/**/*.html', ['html']);
});
gulp.task('build', function(cb) {
runSequence('clean', ['source-js', 'source-sass', 'demo-sass', 'html', 'images'], cb);
});
gulp.task('default', ['build']);