-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
67 lines (59 loc) · 1.77 KB
/
Copy pathgulpfile.js
File metadata and controls
67 lines (59 loc) · 1.77 KB
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
/**
* Gulp Config — Bricks Animation Addons
* Generates a distributable plugin zip.
*
* Includes: all PHP, TXT, and every folder in the plugin root.
* Excludes: node_modules, src, dist (build output), and the gulpfile itself.
*
* Usage:
* npx gulp watch:zip # rebuild on change
*/
const path = require('path');
const gulp = require('gulp');
const zip = require('gulp-zip');
const del = require('del');
const through = require('through2');
const PLUGIN_SLUG = 'bricksfly-elements-for-bricks';
const DIST_DIR = 'dist';
const sources = [
'**/*',
'!node_modules/**', '!node_modules',
// Source font files are excluded — webpack emits hashed copies into
// public/build/fonts/ — but the OFL license text must ship with them.
'!public/fonts/**', 'public/fonts/OFL.txt', '!src',
'!dist/**', '!dist',
'!gulpfile.js',
'!package-lock.json',
'!dist/**',
'!webpack.config.dev',
'!webpack.config.production',
'!CLAUDE.md',
'!**/*.map',
'!**/.DS_Store',
];
// Prefix every file path with the plugin slug so the zip extracts
function prefixFolder(folder) {
return through.obj(function (file, _, cb) {
if (file.relative) {
file.path = path.join(file.base, folder, file.relative);
}
cb(null, file);
});
}
gulp.task('clean:zip', () => {
return del([`${DIST_DIR}/${PLUGIN_SLUG}.zip`]);
});
gulp.task('zip', gulp.series('clean:zip', () => {
return gulp.src(sources, { base: '.', dot: false })
.pipe(prefixFolder(PLUGIN_SLUG))
.pipe(zip(`${PLUGIN_SLUG}.zip`))
.pipe(gulp.dest(DIST_DIR));
}));
gulp.task('watch:zip', () => {
return gulp.watch(
sources,
{ ignoreInitial: false },
gulp.series('zip')
);
});
gulp.task('default', gulp.series('zip'));