-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
60 lines (55 loc) · 1.19 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
'use strict';
let gulp = require( 'gulp' ),
rename = require( 'gulp-rename' ),
sass = require( 'gulp-sass' )( require( 'node-sass' ) ),
sourcemaps = require( 'gulp-sourcemaps' ),
cssmin = require( 'gulp-clean-css' ),
uglify = require( 'gulp-uglify-es' ).default;
gulp.task(
'css:build',
function () {
return gulp.src( './assets/css/*.scss' )
.pipe( sourcemaps.init() )
.pipe( sass().on( 'error', sass.logError ) )
.pipe( gulp.dest( './assets/css' ) )
.pipe( cssmin() )
.pipe(
rename(
{
suffix: '.min',
}
)
)
.pipe( sourcemaps.write( '.' ) )
.pipe( gulp.dest( './assets/css' ) );
}
);
gulp.task(
'css:build:watch',
function () {
gulp.watch( './assets/css/*.scss', gulp.parallel( 'css:build' ) );
}
);
gulp.task(
'js:build',
function () {
return gulp.src( ['./assets/js/*.js', '!./assets/js/*.min.js'] )
.pipe( sourcemaps.init() )
.pipe( uglify() )
.pipe(
rename(
function (path) {
path.extname = '.min.js';
}
)
)
.pipe( sourcemaps.write( '.' ) )
.pipe( gulp.dest( './assets/js' ) );
}
);
gulp.task(
'js:build:watch',
function () {
gulp.watch( './assets/js/*.js', gulp.parallel( 'js:build' ) );
}
);