-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
84 lines (68 loc) · 2 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
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var minifyCss = require('gulp-clean-css');
var headerComment = require('gulp-header-comment');
var { src, series, parallel, dest, watch } = require('gulp');
var browsersync = require("browser-sync").create();
var pjson = require('./package.json');
var jsPath = 'src/fullview.js';
var cssPath = 'src/fullview.css';
// BrowserSync
function browserSync(done) {
browsersync.init({
server: {
baseDir: "./"
},
port: 3000
}, function () {
// something you want to do
});
done();
}
// BrowserSync reload
function browserSyncReload(done) {
browsersync.reload();
done();
}
function jsTask() {
return src(jsPath)
.pipe(sourcemaps.init())
.pipe(headerComment('fullView v' + pjson.version))
.pipe(dest('./dist'))
.pipe(uglify({
output: {
comments: 'some'
}
}))
.pipe(rename({ suffix: '.min' }))
.pipe(sourcemaps.write('.'))
.pipe(headerComment('fullView v' + pjson.version))
.pipe(dest('./dist'))
.pipe(browsersync.stream());
}
function cssTask() {
return src(cssPath)
.pipe(sourcemaps.init())
.pipe(headerComment('fullView v' + pjson.version))
.pipe(dest('./dist'))
.pipe(minifyCss({
compatibility: 'ie8',
advanced: false,
keepSpecialComments: '1'
}))
.pipe(rename({ suffix: '.min' }))
.pipe(sourcemaps.write('.'))
.pipe(headerComment('fullView v' + pjson.version))
.pipe(dest('./dist'))
.pipe(browsersync.stream());
};
function watchTask() {
watch([cssPath, jsPath], { interval: 1000 }, parallel(cssTask, jsTask, browserSync));
watch("./**/*.html", browserSyncReload);
}
exports.watch = series(
parallel(jsTask, cssTask, browserSync),
watchTask
);
exports.default = parallel(jsTask, cssTask);