代码拉取完成,页面将自动刷新
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
);
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。