forked from mcguffin/polylang-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
83 lines (68 loc) · 2.16 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
var autoprefixer = require('gulp-autoprefixer'),
concat = require('gulp-concat'),
gulp = require('gulp'),
gulputil = require('gulp-util'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require('gulp-uglify');
function do_scss( src ) {
var dir = src.substring( 0, src.lastIndexOf('/') );
return gulp.src( './src/scss/' + src + '.scss' )
.pipe( sourcemaps.init() )
.pipe( sass( { outputStyle: 'compressed' } ).on('error', sass.logError) )
.pipe( autoprefixer({
browsers:['last 2 versions']
}) )
.pipe( gulp.dest( './css/' + dir ) )
.pipe( sass( { outputStyle: 'compressed' } ).on('error', sass.logError) )
.pipe( rename( { suffix: '.dev' } ) )
.pipe( sourcemaps.write() )
.pipe( gulp.dest( './css/' + dir ) );
}
function do_js( src ) {
var dir = src.substring( 0, src.lastIndexOf('/') );
return gulp.src( './src/js/' + src + '.js' )
.pipe( sourcemaps.init() )
.pipe( gulp.dest( './js/' + dir ) )
.pipe( uglify() )
.pipe( rename( { suffix: '.dev' } ) )
.pipe( sourcemaps.write() )
.pipe( gulp.dest( './js/' + dir ) );
}
function concat_js( src, dest ) {
return gulp.src( src )
.pipe( sourcemaps.init() )
.pipe( uglify() )
.pipe( concat( dest ) )
.pipe( gulp.dest( './js/' ) )
.pipe( rename( { suffix: '.dev' } ) )
.pipe( sourcemaps.write() )
.pipe( gulp.dest( './js/' ) );
}
// scss tasks
// scss admin tasks
gulp.task('scss:post', function(){
return do_scss('admin/post')
});
// scss
gulp.task('scss', gulp.parallel( 'scss:post' ));
// admin js
gulp.task( 'js:admin', function(){
return do_js( 'admin/admin' );
} );
gulp.task( 'js:nav-menus', function(){
return do_js( 'admin/nav-menus' );
} );
gulp.task( 'js:frontend', function(){
return concat_js( [
], 'frontend.js');
} );
gulp.task('js', gulp.parallel( 'js:admin','js:nav-menus' ) );
gulp.task('build', gulp.parallel('js','scss') );
gulp.task('watch', function() {
// place code for your default task here
gulp.watch('./src/scss/**/*.scss',gulp.parallel( 'scss' ));
gulp.watch('./src/js/**/*.js',gulp.parallel( 'js' ) );
});
gulp.task('default', gulp.parallel('build','watch'));