-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
76 lines (68 loc) · 2.08 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
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var stripDebug = require('gulp-strip-debug');
var webserver = require('gulp-webserver');
var rename = require('gulp-rename');
const fs = require('fs');
var header = require('gulp-header');
var cleanCSS = require('gulp-clean-css');
var replace = require('gulp-replace');
var src_dir = 'working/src';
var dist_dir = 'working/dist';
var proj_name = 'pisonSlider';
// source
gulp.task('src_view',function() {
return gulp.src(src_dir)
.pipe(webserver({
host:'localhost',
// host:'0.0.0.0',
livereload: true,
directoryListing: false,
open:true
}));
});
// distribute
gulp.task('dist_view',function() {
return gulp.src(dist_dir)
.pipe(webserver({
host:'localhost',
// host:'0.0.0.0',
livereload: true,
directoryListing: false,
open:true
}));
});
gulp.task('js-build', function() {
return gulp.src(src_dir+'/**/*.js')
.pipe(concat('jquery.'+proj_name+'.min.js'))
.pipe(stripDebug())
.pipe(uglify())
.pipe(header(fs.readFileSync(src_dir+'/SOURCE.HEADER')))
.pipe(gulp.dest(dist_dir+'/'+proj_name));
})
gulp.task('css-build', function() {
return gulp.src(src_dir+'/**/*.css')
.pipe(concat('jquery.'+proj_name+'.min.css'))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(rename('jquery.'+proj_name+'.min.css'))
.pipe(header(fs.readFileSync(src_dir+'/SOURCE.HEADER')))
.pipe(gulp.dest(dist_dir+'/'+proj_name));
})
gulp.task('html-build', function () {
return gulp.src(src_dir+'/**/*.html')
.pipe(replace('jquery.'+proj_name+'.','jquery.'+proj_name+'.min.'))
.pipe(gulp.dest(dist_dir));
});
gulp.task('build', gulp.series(gulp.parallel('js-build','css-build','html-build'), function() {
// copying
return gulp.src([src_dir+'/**/*',
'!'+src_dir+'/'+proj_name+'/jquery.'+proj_name+'*',
'!'+src_dir+'/SOURCE.*',
'!'+src_dir+'/index.html',
'!'+src_dir+'/single_image.html'
])
.pipe(gulp.dest(dist_dir))
.on('end', ()=> { console.log('Build Completed!'); })
}));
gulp.task('default', gulp.series('build'));