1 Star 0 Fork 110

yujunlee/ZKEACMS

forked from ZKEASOFT/ZKEACMS 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gulpfile.js 2.04 KB
一键复制 编辑 原始数据 按行查看 历史
ZKEASOFT 提交于 2020-11-22 09:57 . Minify js support ES6
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();
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/yujunlee/ZKEACMS.Core.git
[email protected]:yujunlee/ZKEACMS.Core.git
yujunlee
ZKEACMS.Core
ZKEACMS
master

搜索帮助