-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
63 lines (54 loc) · 1.37 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
#!/usr/bin/env node
'use strict';
var gulp = require('gulp'),
sass = require('gulp-sass'),
connect = require('gulp-connect'),
open = require('gulp-open'),
plumber = require('gulp-plumber'),
config = {
server: '0.0.0.0',
port: 3000
};
/* connect */
gulp.task('connect', function() {
connect.server({
port: config.port,
livereload: true,
root: 'example'
});
});
/* htmls */
gulp.task('htmls', function() {
return gulp.src('**/*.html')
.pipe(connect.reload());
});
/* styles */
gulp.task('styles', function() {
return gulp.src('example/css/main.sass')
.pipe(plumber())
.pipe(sass())
.pipe(plumber.stop())
.pipe(gulp.dest('example/css'))
.pipe(connect.reload());
});
/* scripts */
gulp.task('scripts', function() {
return gulp.src('assets/js/**/*.js')
.pipe(connect.reload());
});
gulp.task('watch', function() {
/* watch .html files */
gulp.watch('**/*.html', ['htmls']);
/* watch .sass|.scss files */
gulp.watch('example/css/**/*+(.sass|.scss|.css)', ['styles']);
/* watch .js files */
gulp.watch('assets/js/**/*.js', ['scripts']);
});
gulp.task('open', function() {
var option = {
url: 'http://localhost:' + config.port
};
gulp.src('example/index.html')
.pipe(open('', option));
});
gulp.task('default', ['connect', 'styles', 'scripts', 'htmls', 'watch', 'open']);