forked from richgilbank/Scratch-JS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (66 loc) · 1.8 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
var gulp = require('gulp'),
tinylr = require('tiny-lr'),
usemin = require('gulp-usemin'),
del = require('del'),
zip = require('gulp-zip'),
mfst = require('./manifest.json'),
stylus = require('gulp-stylus'),
debug = require('gulp-debug');
var FILES = {
copy: [
'*.*',
'node_modules',
'{art,art/**}',
'!{panel,panel/**}',
'!package.json',
'!gulpfile.js'
].concat('{' + mfst.web_accessible_resources.join(',') + ',!node_modules/**}'),
watch: ['panel/**/*.{js,css,html}'],
stylusRoot: 'panel/styles/',
stylusGlob: 'panel/styles/**/*.styl',
stylus: 'panel/styles/repl.styl',
panel: 'panel/repl.html',
dist: 'dist/',
distPanel: 'dist/panel/',
distAll: 'dist/**',
zip: 'Scratch JS.zip',
root: './'
}
gulp.task('stylus', function() {
return gulp.src(FILES.stylus)
.pipe(stylus())
.pipe(gulp.dest(FILES.stylusRoot));
});
gulp.task('dev', gulp.series('stylus', function () {
var lr = tinylr();
lr.listen(35729);
gulp.watch(FILES.stylusGlob, gulp.series('stylus'));
gulp.watch(FILES.watch, function (evt) {
lr.changed({
body: {
files: [evt.path]
}
});
});
}));
gulp.task('clean', function() {
return del([FILES.distAll, FILES.zip], {force: true});
});
gulp.task('copy', function() {
return gulp.src(FILES.copy)
.pipe(gulp.dest(FILES.dist));
});
gulp.task('usemin', function() {
return gulp.src(FILES.panel)
.pipe(debug({title: 'usemin:'}))
.pipe(usemin())
.pipe(debug({title: 'dest:'}))
.pipe(gulp.dest(FILES.distPanel));
});
gulp.task('zip', gulp.series('stylus', 'clean', 'usemin', 'copy', function() {
return gulp.src(FILES.distAll)
.pipe(zip(FILES.zip))
.pipe(gulp.dest(FILES.root));
}));
gulp.task('default', gulp.series('dev'));
gulp.task('build', gulp.series('zip'));