-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
68 lines (54 loc) · 1.61 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
// Just Change folder Name in 'Path';
//Install all @required packages
const themePath = './assets/';
const gulp = require( 'gulp' );
const less = require( 'gulp-less' );
const cleanCSS = require( 'gulp-clean-css' );
const rename = require( 'gulp-rename' );
const terser = require('gulp-terser');
/* Task to compile less */
const compileLess = () => {
return gulp.src( themePath + 'less/*.less' )
.pipe( less() )
.pipe(gulp.dest( themePath + 'build/css/' ) );
};
/*Minify CSS*/
const minifyCss = () => {
return gulp.src( themePath + 'build/css/*.css' )
.pipe(cleanCSS( { compatibility: 'ie8' } ) )
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest( themePath + 'dist/css/' ) );
};
/* Minify JS*/
const minifyJs = () => {
return gulp.src(themePath + 'build/js/*.js')
.pipe(terser())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(themePath + 'dist/js/'));
}
/*Watch JS*/
const watchJs = () => {
gulp.watch(themePath + 'build/js/*.js', minifyJs );
};
/*Watch LESS*/
const watchLess = () => {
gulp.watch(themePath + 'less/**/*.less' , compileLess );
};
/*Watch CSS*/
const watchCss = () => {
gulp.watch(themePath + 'build/css/*.css' , minifyCss );
};
/* Task when running `gulp` from terminal */
const build = gulp.parallel( watchLess, watchCss, watchJs );
/* Tasks when running `gulp` from terminal */
exports.compileLess = compileLess;
exports.minifyCss = minifyCss;
exports.minifyJs = minifyJs;
exports.watchLess = watchLess;
exports.watchCss = watchCss;
exports.watchJs = watchJs;
gulp.task( 'default', build );