forked from lmgonzalves/segment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (51 loc) · 1.47 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
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', 'compress'], function() {
browserSync.init({
server: {
baseDir: "./"
}
});
gulp.watch('scss/*.scss', ['sass']);
gulp.watch('dist/segment.js', ['compress']);
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 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(gulp.dest('css'))
.pipe(browserSync.reload({stream:true}));
});
/**
* Create min version
*/
gulp.task('compress', function() {
return gulp.src('dist/segment.js')
.pipe(uglify({preserveComments: 'some'}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist'))
.pipe(rename({basename: 'segment.node'}))
.pipe(insert.append('module.exports=Segment;'))
.pipe(gulp.dest('dist'))
.pipe(browserSync.reload({stream:true}));
});
/**
* Default task
*/
gulp.task('default', ['serve']);