-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
118 lines (99 loc) · 1.73 KB
/
gulpfile.babel.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
/* jshint esnext: true */
'use strict';
/**
* External dependencies.
*/
const {
series,
parallel,
watch
} = require( 'gulp' );
const { src, dest } = require( 'gulp' );
const sass = require( 'gulp-sass' )( require( 'sass' ) );
const autoprefixer = require( 'gulp-autoprefixer' );
const cleancss = require( 'gulp-clean-css' );
const change = require( 'gulp-change' );
const rename = require( 'gulp-rename' );
const plumber = require( 'gulp-plumber' );
const size = require( 'gulp-size' );
const sass_properties = {
indentType: 'tab',
indentWidth: 1,
outputStyle: 'expanded',
precision: 3,
};
/**
* Build SASS files.
*/
export function process_styles() {
const export_path = './dist/'
return src( './scss/*.scss' )
.pipe( plumber() )
.pipe(
sass( sass_properties ).on( 'error', sass.logError )
)
.pipe(
autoprefixer(
{ cascade: false }
)
)
.pipe(
rename(
( path ) => { path.extname = '.css'; }
)
)
.pipe(
dest( export_path )
)
.pipe(
change( removeComments )
)
.pipe(
cleancss( {
level: 2,
} )
)
.pipe(
rename(
( path ) => { path.extname = '.min.css'; }
)
)
.pipe(
size(
{
showFiles: true,
}
)
)
.pipe(
size(
{
showFiles: true,
gzip: true
}
)
)
.pipe(
dest( export_path )
);
}
/**
* Remove comments from the source so that they can be minified away.
*/
const removeComments = function( content ) {
content = content.replace( /\/\*\*!/g, '/**' );
content = content.replace( /\/\*!/g, '/*' );
return content;
};
export const build = process_styles;
export const watchFiles = function( done ) {
watch(
'./scss/**/*.scss',
process_styles
);
done();
};
export default series(
build,
watchFiles
);