This repository has been archived by the owner on Nov 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
gulpfile.js
92 lines (79 loc) · 2.71 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
88
89
90
91
92
var gulp = require('gulp'),
gutil = require('gulp-util'),
header = require('gulp-header'),
concat = require('gulp-concat'),
runSequence = require('run-sequence'),
rename = require('gulp-rename'),
cleanCSS = require('gulp-clean-css'),
uglify = require('gulp-uglify'),
del = require('del'),
express = require('express'),
browserSync = require('browser-sync'),
paths = {
dist: './dist/',
styles: './src/*.css',
fonts: './src/*.{ttf,otf}',
res: ['LICENSE','package.json'],
template: './templates/**',
scripts: ['./src/head.js','./src/init_var.js','./src/util.js','./src/parsejson.js','./src/step.js','./src/cli.js',
'./src/utilregexp.js','./src/modal.js','./src/commandvalidation.js','./src/functions.js',
'./src/nano.js','./src/nano_events.js','./src/file.js','./src/events.js','./src/defaults.js',
'./src/init.js','./src/foot.js']
};
var about = "/* \n" +
" * cli_guide plugin \n" +
" * Original author: @willrre \n" +
" * Further changes, comments: @willrre \n" +
" * Licensed under the MIT license \n" +
" */\n\n";
var server;
function reload() {
if (server) {
return browserSync.reload({ stream: true });
}
return gutil.noop();
}
gulp.task('clean', function() {
return del([paths.dist]);
});
gulp.task('publish', function() {
return gulp.src(paths.res)
.pipe(gulp.dest(paths.dist));
});
gulp.task('copy-fonts', function() {
return gulp.src([paths.fonts])
.pipe(gulp.dest(paths.dist));
});
gulp.task('styles', function() {
return gulp.src(paths.styles)
.pipe(concat('cli_guide.css'))
.pipe(cleanCSS())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(paths.dist))
.pipe(reload());
});
gulp.task('scripts', function() {
return gulp.src(paths.scripts)
.pipe(concat('cli_guide.js'))
.pipe(gulp.dest(paths.dist))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(header(about))
.pipe(gulp.dest(paths.dist))
.pipe(reload());
});
gulp.task('server', function() {
server = express();
server.use(express.static('./'));
server.listen(3000);
browserSync({ proxy: 'localhost:3000' });
});
gulp.task('build', function(){
runSequence('clean',['styles', 'scripts', 'copy-fonts', 'publish']);
});
gulp.task('watch', function() {
gulp.watch(['./src/*.js'], ['scripts']);
gulp.watch(['./src/*.css'], ['styles']);
});
gulp.task('default', ['build']); // is for publish
gulp.task('develop', ['build', 'watch', 'server']);