1 Star 0 Fork 0

左小月半.js/scysuper_app

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
gulpfile.js 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
左小月半.js 提交于 2018-07-07 15:52 . base
/*
* 说明:gulp配置文件
*/
var gulp = require('gulp'),
Less = require('gulp-less'),
cleanCSS = require('gulp-clean-css'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
pump = require('pump'),
autoprefixer = require('gulp-autoprefixer');
var assets={
less: './src/less/page/*.less',
config: './src/js/config/*.js',
page: './src/js/page/*.js',
util: './src/js/util/*.js'
};
function less (cb){
pump([
gulp.src( './src/less/app.less'),
Less(),
autoprefixer({ browsers: ['last 2 versions'], cascade: false }),
cleanCSS(),
gulp.dest('assets/css')
], cb);
}
function config (cb){
pump([
gulp.src(assets.config),
concat('config.js'),
uglify(),
gulp.dest('assets/js')
], cb);
}
function util (cb){
pump([
gulp.src(assets.util),
concat('util.js'),
uglify(),
gulp.dest('assets/js')
], cb);
}
function page (cb){
pump([
gulp.src(assets.page),
uglify(),
gulp.dest('assets/js/page')
], cb);
}
//编译less
gulp.task('less', function (cb) {
less(cb)
});
//压缩合并config
gulp.task('config', function (cb) {
config(cb)
});
//压缩合并util
gulp.task('util', function (cb) {
util(cb)
});
//压缩page js
gulp.task('page', function (cb) {
page(cb)
});
//监听文件变化
gulp.task('watch',['config', 'util', 'page', 'less'], function(cb){
//监听config文件修改
var configWatcher = gulp.watch(assets.config,['config']);
configWatcher.on('change',function(event){
console.log('Config:File ' + event.path + ' was ' + event.type + ', running tasks...');
});
//监听util文件修改
var utilWatcher = gulp.watch(assets.util,['util']);
utilWatcher.on('change',function(event){
console.log('Util:File ' + event.path + ' was ' + event.type + ', running tasks...');
});
//监听page文件修改
var pageWatcher = gulp.watch(assets.page,['page']);
pageWatcher.on('change',function(event){
console.log('Page:File ' + event.path + ' was ' + event.type + ', running tasks...');
});
//监听less文件修改
var lessWatcher = gulp.watch(assets.less,['less']);
lessWatcher.on('change',function(event){
console.log('Less:File ' + event.path + ' was ' + event.type + ', running tasks...');
});
});
//默认任务
gulp.task('default', ['less','config','util','page']);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zuowuzhou/scysuper_app.git
git@gitee.com:zuowuzhou/scysuper_app.git
zuowuzhou
scysuper_app
scysuper_app
master

搜索帮助