1 Star 0 Fork 0

健康蛀牙/douxiaoli1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
gulpfile.js 2.82 KB
一键复制 编辑 原始数据 按行查看 历史
luo 提交于 2017-09-07 18:04 . 浏览器首页
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();
var useref = require('gulp-useref');
var uglify = require('gulp-uglify');
var gulpIf = require('gulp-if');
var cssnano = require('gulp-cssnano');
var imagemin = require('gulp-imagemin');
var cache = require('gulp-cache');
var rename = require('gulp-rename');
var del = require('del');
var runSequence = require('run-sequence');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var minifyCss = require('gulp-minify-css');
var sh = require('shelljs');
var ngmin = require('gulp-ngmin');
var stripDebug = require('gulp-strip-debug');
gulp.task('browserSync',function(){
browserSync.init({
port:80,
server: {
baseDir:'./app',
proxy:'http://admin.bigoedu.com'
},
});
gulp.watch('./app/**/*.html').on('change',browserSync.reload);
gulp.watch('./app/css/*.css').on('change',browserSync.reload);
gulp.watch('./app/js/**/*.js').on('change',browserSync.reload);
// Sass编译完成后再刷新
gulp.watch('./app/sass/*.scss',['sass']);
});
// 压缩js
gulp.task('minify',
function() {
return gulp.src('./app/js/**/*.js').pipe(ngmin({
dynamic: false
}))
.pipe(stripDebug()).pipe(uglify({
outSourceMap: false
}))
.pipe(gulp.dest('./dist/js/'));
});
// 编译sass
gulp.task('sass',function(){
return gulp.src('./app/sass/**/*.scss')
.pipe(sass({outputStyle:'compact'}))
.pipe(gulp.dest('./app/css'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('useref',function(){
return gulp.src('./app/*.html')
.pipe(useref())
.pipe(gulp.dest('./dist'));
});
gulp.task('userefTpl',function(){
return gulp.src('./app/tpl/**/*.html')
.pipe(useref())
.pipe(gulp.dest('./dist/tpl'));
});
gulp.task('images', function(){
return gulp.src('./app/img/**/*.+(png|jpg|jpeg|gif|svg|ico)')
.pipe(gulp.dest('./dist/img'));
});
gulp.task('fonts',function(){
return gulp.src('./app/fonts/**/*')
.pipe(gulp.dest('./dist/fonts'));
});
gulp.task('vendor',function(){
return gulp.src('./app/vendor/**/*')
.pipe(gulp.dest('./dist/vendor/'));
});
gulp.task('cssMinify',function(){
return gulp.src("./app/css/*.css")
.pipe(gulpIf('*.css',cssnano()))
.pipe(gulp.dest("./dist/css"))
})
gulp.task('clean:dist',function(){
return del.sync('./dist');
});
gulp.task('cache:clear',function(callback){
return cache.clearAll(callback);
});
gulp.task('default',function(callback){
runSequence(['sass','browserSync'],
callback
);
});
gulp.task('build',function(callback){
runSequence('clean:dist',
['sass','useref','fonts','minify','cssMinify','userefTpl','images','vendor'],
callback
);
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/caipeiyu/douxiaoli1.git
git@gitee.com:caipeiyu/douxiaoli1.git
caipeiyu
douxiaoli1
douxiaoli1
master

搜索帮助