forked from BoldGrid/post-and-page-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
121 lines (113 loc) · 2.54 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/**
* Automatically Copies Deps from Framework:
* FontAwesome
* jquery-stellar
* components.css
* bootstrap.min.css
* font-family-controls.min.css
*/
var gulp = require( 'gulp' ),
cssnano = require( 'gulp-cssnano' ),
rename = require( 'gulp-rename' ),
sass = require( 'gulp-sass' ),
debug = require( 'gulp-debug' ),
uglify = require( 'gulp-uglify' ),
concat = require( 'gulp-concat' ),
sequence = require( 'run-sequence' ),
del = require( 'del' ),
fs = require( 'fs' ),
autoprefixer = require( 'gulp-autoprefixer' ),
gutil = require( 'gutil' ),
pump = require( 'pump' );
// Configs.
var config = {
src: './',
dist: './',
fontDest: './assets/fonts',
buildDest: './build',
cssDest: './assets/css',
jsDest: './assets/js',
jsonDir: './assets/json'
};
// Compile sass files.
gulp.task( 'sass', function() {
gulp
.src( [
config.dist + '/assets/scss/**/*.scss',
'!' + config.src + 'assets/scss/color-palette-scss/**/*'
] )
.pipe(
sass( {
includePaths: [ config.dist + 'assets/scss/' ]
} ).on( 'error', sass.logError )
)
.pipe( sass.sync().on( 'error', sass.logError ) )
.pipe(
autoprefixer( {
browsers: [ '> 1%', 'Last 2 versions' ],
cascade: false
} )
)
.pipe( gulp.dest( config.dist + '/assets/css' ) )
.pipe(
cssnano( {
discardComments: { removeAll: true },
zindex: false
} )
)
.pipe( rename( { suffix: '.min' } ) )
.pipe( gulp.dest( config.dist + '/assets/css' ) );
} );
gulp.task( 'merge-webpack', function() {
gulp
.src( [
config.dist + '/assets/css/editor.min.css',
config.dist + '/assets/css/bundle.min.css'
] )
.pipe(
autoprefixer( {
browsers: [ '> 5%' ],
cascade: false
} )
)
.pipe( concat( 'editor.min.css' ) )
.pipe( gulp.dest( config.dist + '/assets/css/' ) );
} );
gulp.task( 'jsmin-media', function( cb ) {
pump(
[
gulp.src( [
'!' + config.src + 'assets/js/media/**/*.min.js',
config.src + 'assets/js/media/**/*.js'
] ),
uglify(),
rename( {
suffix: '.min'
} ),
gulp.dest( config.dist + 'assets/js/media' )
],
cb
);
} );
gulp.task( 'jsmin-editor', function( cb ) {
pump(
[
gulp.src( [
'!' + config.src + 'assets/js/editor/**/*.min.js',
config.src + 'assets/js/editor/**/*.js'
] ),
uglify(),
rename( {
suffix: '.min'
} ),
gulp.dest( config.dist + 'assets/js/editor' )
],
cb
);
} );
gulp.task( 'build', function( cb ) {
sequence( [ 'sass', 'jsmin-editor', 'jsmin-media' ], cb );
} );
gulp.task( 'watch', function() {
gulp.watch( config.src + 'assets/scss/**/*', [ 'sass' ] );
} );