-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (74 loc) · 2.17 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
84
85
86
87
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var minifycss = require('gulp-minify-css');
var minifyhtml = require('gulp-minify-html');
var browserSync = require('browser-sync').create();
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var reload = browserSync.reload;
var Path = {
html: 'src/index.html',
js: 'src/js/main.js',
css: 'src/css/**/*.css',
image: 'src/img/**/*',
slide: 'src/content/*.md',
libs: 'src/libs/**/*',
dist: 'dist',
distJs: 'dist/js',
distCss: 'dist/css',
distImage: 'dist/img',
distLibs: 'dist/libs'
};
gulp.task('server', ['libs', 'uglify', 'minifycss', 'minifyhtml', 'slide', 'images'], function () {
return browserSync.init({
server: {
baseDir: './dist'
}
});
});
gulp.task('images', function () {
return gulp.src(Path.image)
.pipe(gulp.dest(Path.distImage));
});
gulp.task('libs', function () {
return gulp.src(Path.libs)
.pipe(gulp.dest(Path.distLibs));
});
gulp.task('minifycss', function () {
return gulp.src(Path.css)
.pipe(concat('main.css'))
.pipe(minifycss())
.pipe(gulp.dest(Path.distCss))
.pipe(reload({stream: true}));
});
gulp.task('uglify', function () {
return browserify(Path.js)
.bundle()
.pipe(source('main.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest(Path.distJs))
.pipe(reload({stream: true}));
});
gulp.task('slide', function () {
return gulp.src(Path.slide)
.pipe(concat('slide.md'))
.pipe(gulp.dest(Path.dist))
.pipe(reload({stream: true}));
});
gulp.task('minifyhtml', function () {
return gulp.src(Path.html)
.pipe(minifyhtml())
.pipe(gulp.dest(Path.dist))
.pipe(reload({stream: true}));
});
// ���� ���� ����
gulp.task('watch', function () {
gulp.watch(Path.js, ['uglify']);
gulp.watch(Path.css, ['minifycss']);
gulp.watch(Path.html, ['minifyhtml']);
gulp.watch(Path.slide, ['slide']);
});
gulp.task('default', ['server', 'watch']);