-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
54 lines (45 loc) Β· 1.1 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
const { src, dest, series, task } = require('gulp')
const dels = require('del')
const replace = require('gulp-replace')
const zip = require('gulp-zip')
const watch = require('gulp-watch')
const project = require('./package')
function name() {
let package = require('./package')
return package.name
}
function file() {
let package = require('./package')
return `${package.name}-${package.version}.zip`
}
function version() {
let package = require('./package')
return package.version
}
function date() {
return new Date().toJSON()
}
// Clean dist folder
function clean() {
return dels([
'build/*',
'dist/*'
]);
}
// Build package replacing variables
function build() {
return src('src/**')
.pipe(replace('PLUGIN_VERSION', version()))
.pipe(dest(`build/${name()}`))
}
// Package the project
function pack() {
return src(`build/**`)
.pipe(zip(file()))
.pipe(dest('dist/'))
}
task('watch', function () {
return watch('src/**', series(clean, build, pack))
})
// Export default task
exports.default = series(clean, build, pack)