forked from SeriaWei/ZKEACMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (62 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
65
var gulp = require('gulp');
var less = require('gulp-less');
var sourcemaps = require('gulp-sourcemaps');
var cleanCSS = require('gulp-clean-css');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify-es').default;
var saveLicense = require('uglify-save-license');
function handleError(err) {
console.log(err.toString());
this.emit('end');
}
function compileTheme(theme) {
gulp.src('src/ZKEACMS.WebHost/wwwroot/themes/' + theme + '/css/Theme.less')
.pipe(sourcemaps.init())
.pipe(less())
.on("error", handleError)
.pipe(sourcemaps.write())
.pipe(gulp.dest(function (f) {
return f.base;
}))
.pipe(cleanCSS({ inline: ['none'] }))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(function (f) {
return f.base;
}));
}
function themeFilter(theme) {
return 'src/ZKEACMS.WebHost/wwwroot/themes/' + theme + '/css/*.less';
}
gulp.task('compile-theme:default', function (cb) {
compileTheme('Default');
cb();
});
gulp.task('watch:minify-js-css', function (cb) {
gulp.watch(themeFilter('Default'), gulp.series('compile-theme:default'));
var jsWatch = gulp.watch(['src/**/*.js', '!src/**/*.min.js']);
jsWatch.on('change', function (path, stats) {
console.log(`Minify ${path}`);
gulp.src(path)
.pipe(uglify({ output: { comments: saveLicense } }))
.on("error", handleError)
.pipe(rename({ suffix: ".min" }))
.pipe(gulp.dest(function (f) {
return f.base;
}));
});
var cssWatch = gulp.watch(['src/**/*.css', '!src/**/*.min.css', '!src/ZKEACMS.WebHost/wwwroot/themes/**/*.css']);
cssWatch.on('change', function (path) {
console.log(`Minify ${path}`);
gulp.src(path)
.pipe(cleanCSS({ inline: ['none'] }))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(function (f) {
return f.base;
}));
});
cb();
});