-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (62 loc) · 1.65 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
"use strict";
var gulp = require('gulp');
var concatCss = require('gulp-concat-css');
var rename = require('gulp-rename');
var notify = require('gulp-notify');
var prefix = require('gulp-autoprefixer');
var livereload = require('gulp-livereload');
var connect = require('gulp-connect');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');
var open = require('gulp-open');
//server connect
gulp.task('connect', function () {
connect.server({
root: 'app',
livereload: true
});
});
//scss
gulp.task('css', function () {
return gulp.src('scss/*.scss')
.pipe(sass())
.pipe(prefix('last 25 versions'))
.pipe(minifyCSS())
.pipe(rename('style.min.css'))
.pipe(gulp.dest('app/css'))
.pipe(notify("CSS compile OK!"))
.pipe(connect.reload());
});
//js
gulp.task('js', function () {
return gulp.src('js/*.js')
.pipe(uglify())
.pipe(rename('common.min.js'))
.pipe(gulp.dest('app/js'))
.pipe(notify("JS compress OK!"))
.pipe(connect.reload());
});
//html
gulp.task('html', function () {
gulp.src('app/index.html')
.pipe(notify("HTML change OK!"))
.pipe(connect.reload());
});
//open
gulp.task('open', function(){
var options = {
uri: 'localhost:8080',
app: 'firefox'
};
gulp.src('app/index.html')
.pipe(open(options));
});
//watch
gulp.task('watch', function () {
gulp.watch('scss/*.scss', ['css'])
gulp.watch('js/*.js', ['js'])
gulp.watch('app/index.html', ['html'])
});
//default
gulp.task('default', ['connect', 'html', 'css', 'js','open', 'watch']);