-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgulpfile.js
86 lines (78 loc) · 2.03 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
'use strict';
const gulp = require('gulp');
const less = require('gulp-less');
const uglify = require('gulp-uglify');
const cleanCSS = require('gulp-clean-css');
const rename = require("gulp-rename");
const del = require('del');
const pkg = require('./package.json');
gulp.task('less', function (done) {
return gulp.src('assets/css/style.less')
.pipe(less({
plugins: [
new (require('less-plugin-autoprefix'))({ browsers: ["> 1%"] })
]
}))
.pipe(cleanCSS({
compatibility: '*',
//format:'beautify',
level: {
1: {
specialComments:true
},
2: {
}
}
}))
.pipe(gulp.dest('assets/css'));
});
gulp.task('uglify', function () {
return gulp.src(['assets/js/*.js','!assets/js/*.min.js'])
.pipe(uglify({
compress: {
drop_console: true
},
mangle: {
reserved: ['jQuery', 'WPCA', 'RUA','$']
},
output: {
comments: 'some'
},
warnings: false
}))
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest('assets/js'));
});
gulp.task('clean:svn', function () {
return del(['D:/svn/'+pkg.name+'/trunk/**/*'],{force:true});
});
gulp.task('svn', function() {
return gulp.src([
'./**',
'!fs-config.json',
'!docs{,/**}',
'!build{,/**}',
'!vendor{,/**}',
'!src{,/**}',
'!**/composer.*',
'!**/package*.json',
'!**/pnpm-lock.yaml',
'!**/phpdoc.xml',
'!lib/freemius/assets/scripts{,/**}',
'!lib/freemius/gulptasks{,/**}',
'!lib/freemius/patches{,/**}',
'!**/CONTRIBUTING.md',
'!**/*.{less,scss,po,pot,js}',
'!**/{scss,less}{,/**}',
'{lib/freemius/assets/js/*,**/*.min}.js',
'!**/node_modules{,/**}'
])
.pipe(gulp.dest('D:/svn/'+pkg.name+'/trunk'));
});
gulp.task('watch', function() {
gulp.watch('assets/css/style.less', gulp.parallel('less'));
gulp.watch(['assets/js/*.js','!assets/js/*.min.js'], gulp.parallel('uglify'));
});
gulp.task('build', gulp.parallel('less','uglify'));
gulp.task('deploy', gulp.series('clean:svn','svn'));
gulp.task('default', gulp.parallel('build'));