-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
47 lines (38 loc) · 1.32 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
// Node & NPM packages
const merge = require('merge-stream'),
path = require('path'),
gulp = require('gulp'),
rename = require('gulp-rename'),
zip = require('gulp-zip');
// Custom modules & config
const util = require('./lib/fsUtils');
const dir = {
src:'./src',
dist:'./dist'
}
const srcFolders = util.getFolders(dir.src);
// Gulp Tasks
gulp.task('default', zipFiles);
function zipFiles(cb) {
let task = srcFolders.map(function(folder) {
let _src = path.join(dir.src, folder),// Path source files
_files = _src+'/*.{css,html,js,json,jpg,png,gif}', // Package banner files into the _final zip
_images = _src+'/images/**';
let _final = gulp.src([_files,_images],{base:_src})
.pipe(zip('_final.zip'))
.pipe(rename(function(file){file.basename = folder + file.basename;}))
.pipe(gulp.dest(dir.dist));
let _html = gulp.src(path.join(dir.src, folder,'*.html'))
.pipe(gulp.dest(dir.dist));
/*
Uncomment below to make a _source.zip of all source files except node_modules
*/
// let _source = gulp.src(['*.{json,js,txt,md}', 'lib/**', _src+'/**/*', 'dist'],{base:'./'})
// .pipe(zip('_source.zip'))
// .pipe(rename(function(file){file.basename = folder + file.basename;}))
// .pipe(gulp.dest(dir.dist));
// return merge(_source, _final, _html)
return merge(_final, _html)
});
cb();
};