forked from airalcorn2/strike-with-a-pose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
92 lines (81 loc) · 2.51 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
const $ = require('gulp');
const $bro = require('gulp-bro');
const $changed = require('gulp-changed');
const $concat = require('gulp-concat');
const $htmlmin = require('gulp-htmlmin');
const $plumber = require('gulp-plumber');
const $postcss = require('gulp-postcss');
const $sourcemap = require('gulp-sourcemaps');
const $terser = require('gulp-terser');
const merge2 = require('merge2');
const browserify = require('browserify');
const babelify = require('babelify');
const del = require('del');
const server = require('browser-sync').create();
$.task('build', $.series(clean, $.parallel(pages, styles, assets, scripts)));
$.task('default', $.series('build', $.parallel(serve, watch)));
$.task('publish', publish);
function clean() {
return del(['build']);
}
function reload(done) {
server.reload();
done();
}
function watch() {
$.watch('docs_src/index.html', $.series(pages, reload));
$.watch('docs_src/css/*.css', $.series(styles, reload));
$.watch('docs_src/models/*', $.series(assets, reload));
$.watch('docs_src/js/*', $.series(scripts, reload));
}
function serve(done) {
server.init({server: 'build'});
done();
}
function pages() {
return $.src(['docs_src/index.html'])
.pipe($changed('build'))
.pipe($plumber())
.pipe($htmlmin({
removeComments: true,
collapseWhitespace: true,
removeEmptyAttributes: true,
minifyJS: true,
minifyCSS: true}))
.pipe($.dest('build'));
}
function styles() {
return $.src('docs_src/css/*.css')
.pipe($changed('build'))
.pipe($plumber())
.pipe($postcss([
require('precss'),
require('cssnano')({
autoprefixer: {browsers: ['last 2 version'], add: true},
discardComments: {removeAll: true}})]))
.pipe($.dest('build/css'));
}
function assets() {
var s0 = $.src('docs_src/models/*')
.pipe($changed('build'))
.pipe($.dest('build/models'));
var s1 = $.src('docs_src/img/*')
.pipe($changed('build'))
.pipe($.dest('build/img'));
return merge2(s0, s1);
}
function scripts() {
return $.src(['docs_src/js/jquery.min.js',
'docs_src/js/three.min.js',
'docs_src/js/TrackballControls.js',
'docs_src/js/MTLLoader.js',
'docs_src/js/LoaderSupport.js',
'docs_src/js/OBJLoader2.js',
'docs_src/js/tf.min.js',
'docs_src/js/mobilenet.js',
'docs_src/js/app.js',])
.pipe($.dest('./build/js'));
}
function publish() {
return $.src('./build/**/*').pipe($.dest('./docs'));
}