-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
47 lines (41 loc) · 1.08 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
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
// error handler
// https://github.com/gulpjs/gulp/issues/259
var onError = function(error) {
console.log(error);
this.emit('end');
};
// minify css
gulp.task('sass', function() {
return gulp.src('dist/heading-links.scss')
.pipe(gulp.dest('dist'))
.pipe(plugins.connect.reload());
});
// uglify script
gulp.task('scripts', function() {
return gulp.src('dist/heading-links.js')
.pipe(gulp.dest('dist'))
.pipe(plugins.rename(function(path) {
path.basename = "heading-links.min"
}))
.pipe(plugins.uglify())
.on('error', onError)
.pipe(gulp.dest('dist'))
.pipe(plugins.connect.reload());
});
// localhost:3000
gulp.task('server', function() {
return plugins.connect.server({
root: 'dist',
port: 3000,
livereload: true
});
});
// watch js file
gulp.task('watch', function() {
gulp.watch('dist/heading-links.scss', ['sass']);
gulp.watch('dist/heading-links.js', ['scripts']);
});
// default task
gulp.task('default', ['server', 'sass', 'scripts', 'watch']);