-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
83 lines (63 loc) · 1.52 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
71
72
73
74
75
76
77
78
79
80
81
82
83
global.hostname = "localhost";
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
pump = require('pump'),
watch = require('gulp-watch'),
browserSync = require("browser-sync"),
eslint = require("gulp-eslint"),
reload = browserSync.reload;
var patch = {
src: {
html: '*.html',
css: 'css_src/**/*.css',
js: 'js_src/*.js'
}
};
var config = {
server: {
baseDir: ""
},
tunnel: false,
host: 'localhost',
port: 3000,
logPrefix: "devel43"
};
gulp.task('webserver', function () {
browserSync(config);
});
gulp.task('webserver:reload', function() {
browserSync.reload(["*.css", "*.html", "*.js"]);
})
gulp.task('styles', function () {
gulp.src(patch.src.css)
.pipe(autoprefixer({
browsers: ['last 10 versions'],
cascade: false
}))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('css'))
.pipe(reload({stream: true}));
});
gulp.task('common-js', function() {
gulp.src(patch.src.js)
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('js'))
.pipe(reload({stream: true}));
});
gulp.task('build', ['styles', 'common-js']);
gulp.task('watch', function() {
watch([patch.src.css], function(event, cb) {
gulp.start('styles');
});
watch([patch.src.js], function(event, cb) {
gulp.start('common-js');
});
});
gulp.task('default', ['build', 'webserver', 'watch'], function() {
});