-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (58 loc) · 2.04 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
// Include gulp
var gulp = require('gulp');
// Include plugins
var rename = require( 'gulp-rename' );
var replace = require( 'gulp-replace' );
var concat = require( 'gulp-concat' );
var uglify = require( 'gulp-uglify' );
var sass = require( 'gulp-sass' );
var postcss = require( 'gulp-postcss' );
var sorting = require( 'postcss-sorting' );
var wprtl = require( 'postcss-wprtl' );
// Minify JS
gulp.task( 'minifyjs', function() {
return gulp.src( ['assets/js/navigation.js', 'assets/js/customize-preview.js', 'assets/js/customizer-controls.js'] )
.pipe( uglify() )
.pipe( rename( {
suffix: '.min'
} ) )
.pipe( gulp.dest('assets/js') );
});
// WP RTL
gulp.task( 'wprtl', function () {
return gulp.src( ['style.css'] )
.pipe( concat( 'rtl.css' ) )
.pipe( postcss( [ wprtl() ] ) )
.pipe( postcss( [ sorting( { 'preserve-empty-lines-between-children-rules': true } ) ] ) )
.pipe( gulp.dest( './' ) );
});
// Editor Styles Sass Bundler
gulp.task( 'editor', function() {
return gulp.src( 'sass/editor-styles.scss' )
.pipe( sass( { outputStyle: 'expanded' } ).on( 'error', sass.logError ) )
.pipe( rename( 'editor-styles.css' ) )
.pipe( postcss( [ sorting() ] ) )
.pipe( replace( ' ', ' ' ) )
.pipe( replace( '}\n ', '}\n\n ' ) )
.pipe( replace( '}\n\n }', '}\n }' ) )
.pipe( replace( '*/\n/*', '*/\n\n/*' ) )
.pipe( replace( ';\n /*', '; /*' ) )
.pipe( gulp.dest( 'assets/css' ) )
});
// Sass Bundler
gulp.task( 'sass', function() {
return gulp.src( 'sass/style.scss' )
.pipe( sass( { outputStyle: 'expanded' } ).on( 'error', sass.logError ) )
.pipe( rename( 'style.css' ) )
.pipe( postcss( [ sorting() ] ) )
.pipe( replace( ' ', ' ' ) )
.pipe( replace( '}\n ', '}\n\n ' ) )
.pipe( replace( '}\n\n }', '}\n }' ) )
.pipe( replace( '*/\n/*', '*/\n\n/*' ) )
.pipe( replace( ';\n /*', '; /*' ) )
.pipe( gulp.dest( './' ) )
});
// Sass Watch
gulp.task('sass:watch', function () {
gulp.watch( 'sass/**/*.scss', gulp.parallel('sass', 'editor') );
});