-
Notifications
You must be signed in to change notification settings - Fork 99
/
gulpfile.js
57 lines (52 loc) · 1.4 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
var gulp = require('gulp'),
browserSync = require('browser-sync'),
sass = require('gulp-sass'),
prefix = require('gulp-autoprefixer'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
insert = require('gulp-insert');
/**
* Static server
*/
gulp.task('serve', ['sass', 'dist'], function(){
browserSync.init({
server: {
baseDir: "./"
},
open: false,
online: false,
notify: false
});
gulp.watch('scss/*.scss', ['sass']);
gulp.watch('dist/segment.js', ['dist']);
gulp.watch(['index.html', 'js/*']).on('change', browserSync.reload);
});
/**
* Compile files from scss into css
*/
gulp.task('sass', function(){
return gulp.src('scss/demo.scss')
.pipe(sass({
outputStyle: 'compressed',
includePaths: ['scss'],
onError: browserSync.notify
}))
.pipe(prefix(['last 5 versions'], {cascade: true}))
.pipe(gulp.dest('css'))
.pipe(browserSync.reload({stream:true}));
});
/**
* Create distributable versions
*/
gulp.task('dist', function(){
return gulp.src('js/segment.js')
.pipe(gulp.dest('dist'))
.pipe(uglify({preserveComments: 'some'}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist'))
.pipe(browserSync.reload({stream:true}));
});
/**
* Default task
*/
gulp.task('default', ['serve']);