-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
91 lines (79 loc) · 2.36 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
"use strict";
const gulp = require('gulp');
const sass = require('gulp-sass');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const header = require('gulp-header');
const cleanCss = require('gulp-clean-css');
const pkg = require('./package.json');
function banner() {
const stamp = [
'/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @author <%= pkg.author.name %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''
].join('\n');
return header(stamp, {pkg: pkg});
}
function css() {
return gulp
.src('app/scss/*.scss')
.pipe(sass())
.pipe(gulp.dest('dist/css'))
.pipe(rename('imcrop.min.css'))
.pipe(cleanCss())
.pipe(gulp.dest('dist/css'));
}
function scriptTrackingJs() {
const files = [
'node_modules/tracking/build/tracking.js',
'node_modules/tracking/build/data/face.js',
'node_modules/tracking/build/data/eye.js'
];
return gulp.src(files)
.pipe(concat('tracking.js'))
.pipe(gulp.dest('dist/js'))
.pipe(rename('tracking.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/js'));
}
function scriptCropJs() {
const files = [
'app/js/imcrop.ui.js',
'app/js/imcrop.editor.js',
'app/js/imcrop.ratio.js',
'app/js/imcrop.base.js',
'app/js/imcrop.image.js',
'app/js/imcrop.softcrop.js'
];
return gulp
.src(files)
.pipe(concat('cropjs.js'))
.pipe(banner())
.pipe(gulp.dest('dist/js'))
.pipe(rename('cropjs.min.js'))
.pipe(uglify())
.pipe(banner())
.pipe(gulp.dest('dist/js'))
}
function scriptWorkerDetect() {
return gulp.src('app/js/workers/imcrop.worker.detect.js')
.pipe(uglify())
.pipe(banner())
.pipe(gulp.dest('dist/js'));
}
function watchFiles() {
gulp.watch('app/scss/*.scss', css)
gulp.watch('app/**/*.js', gulp.parallel(scriptCropJs, scriptWorkerDetect))
}
const scripts = gulp.parallel(scriptCropJs, scriptWorkerDetect, scriptTrackingJs);
const build = gulp.parallel(css, scripts);
const watch = gulp.series(build, watchFiles);
exports.watch = watch;
exports.build = build;
exports.default = build;