-
Notifications
You must be signed in to change notification settings - Fork 64
/
gulpfile.js
103 lines (95 loc) · 2.92 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
92
93
94
95
96
97
98
99
100
101
102
103
var gulp = require('gulp');
var sass = require('gulp-sass')(require('sass'));
var autoprefix = require('gulp-autoprefixer');
var livereload = require('gulp-livereload');
var minifycss = require('gulp-minify-css');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
// Paths
var scss = 'assets/scss/**/*';
var css = 'assets/css/';
var js_source = [
'assets/js/lib/nestedpages.formatter.js',
'assets/js/lib/nestedpages.dropdowns.js',
'assets/js/lib/nestedpages.modals.js',
'assets/js/lib/nestedpages.check-all.js',
'assets/js/lib/nestedpages.bulk-actions.js',
'assets/js/lib/nestedpages.hidden-item-count.js',
'assets/js/lib/nestedpages.menu-toggle.js',
'assets/js/lib/nestedpages.page-toggle.js',
'assets/js/lib/nestedpages.nesting.js',
'assets/js/lib/nestedpages.sync-menu-setting.js',
'assets/js/lib/nestedpages.new-post.js',
'assets/js/lib/nestedpages.quickedit-post.js',
'assets/js/lib/nestedpages.quickedit-link.js',
'assets/js/lib/nestedpages.clone.js',
'assets/js/lib/nestedpages.tabs.js',
'assets/js/lib/nestedpages-factory.js',
'assets/js/lib/nestedpages.menu-links.js',
'assets/js/lib/nestedpages.menu-search.js',
'assets/js/lib/nestedpages.trash.js',
'assets/js/lib/nestedpages.confirm-delete.js',
'assets/js/lib/nestedpages.manual-sync.js',
'assets/js/lib/nestedpages.post-search.js',
'assets/js/lib/nestedpages.move-post.js',
'assets/js/lib/nestedpages.trash-with-children.js',
'assets/js/lib/nestedpages.wpml.js'
];
var js_source_settings = [
'assets/js/lib/nestedpages.settings-reset.js',
'assets/js/lib/nestedpages.userprefs-reset.js',
'assets/js/lib/nestedpages.settings-admin-customization.js',
'assets/js/lib/nestedpages.settings.js'
];
var js_compiled = 'assets/js/';
/**
* Minify the admin styles and output
*/
var styles = function(){
return gulp.src(scss)
.pipe(sass({sourceComments: 'map', sourceMap: 'sass', style: 'compact'}))
.pipe(autoprefix('last 5 version'))
.pipe(minifycss({keepBreaks: false}))
.pipe(gulp.dest(css))
.pipe(livereload());
}
/**
* Concatenate and minify scripts
*/
var scripts = function(){
return gulp.src(js_source)
.pipe(concat('nestedpages.min.js'))
.pipe(uglify())
.pipe(gulp.dest(js_compiled));
};
/**
* Output unminified JS for dev environment
*/
var scripts_dev = function(){
return gulp.src(js_source)
.pipe(concat('nestedpages.js'))
.pipe(uglify())
.pipe(gulp.dest(js_compiled));
};
/**
* Output the settings JS and output
*/
var scripts_settings = function(){
return gulp.src(js_source_settings)
.pipe(concat('nestedpages.settings.min.js'))
.pipe(uglify())
.pipe(gulp.dest(js_compiled));
};
/**
* Watch Task
*/
gulp.task('watch', function(){
livereload.listen();
gulp.watch(scss, gulp.series(styles));
gulp.watch(js_source, gulp.series(scripts, scripts_dev));
gulp.watch(js_source_settings, gulp.series(scripts_settings));
});
/**
* Default
*/
gulp.task('default', gulp.series(styles, scripts, scripts_dev, scripts_settings, 'watch'));