代码拉取完成,页面将自动刷新
var gulp = require('gulp'),
browserSync = require('browser-sync'),
gulpLoadPlugins = require('gulp-load-plugins'),
plugins = gulpLoadPlugins();
gulp.task('minify',function(){
gulp.src('public/javascripts/*.js')
.pipe(plugins.uglify())
.pipe(gulp.dest('public/js'))
});
gulp.task('js',function(){
return gulp.src('public/javascripts/*.js')
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('default'))
.pipe(plugins.uglify())
.pipe(plugins.concat('app.js'))
.pipe(gulp.dest('public/js'))
});
gulp.task('shell',plugins.shell.task(['npm start']));
//监测coffee文件变化
gulp.task('coffee',function(){
gulp.src('public/coffee/*.coffee')
.pipe(plugins.watch('public/coffee/*.coffee'))
.pipe(plugins.coffee({bare:true}).on('error',plugins.util.log))
.pipe(gulp.dest('public/js'))
.pipe(plugins.livereload())
});
//监测less文件变化
gulp.task('less',function(){
gulp.src('public/stylesheets/*.less')
.pipe(plugins.watch('public/stylesheets/*.less'))
.pipe(plugins.less())
.pipe(gulp.dest('public/css'))
.pipe(plugins.livereload())
});
//监测sass文件变化
gulp.task('sass',function(){
gulp.src('public/sass/**/*.scss')
.pipe(plugins.watch('public/sass/**/*.scss'))
.pipe(plugins.sass({'outputStyle':'compressed'}))
.pipe(gulp.dest('public/css'))
.pipe(plugins.livereload());
});
//监测react变化
gulp.task('react',function(){
gulp.src('public/react/**/*.jsx')
.pipe(plugins.react())
.pipe(gulp.dest('public/js'))
});
//browserSync 检测文件变化
gulp.task('serve',['less','sass','react','coffee','js'],function(){
var config = {
port:3002,
proxy:'127.0.0.1:3030',
files:['views/**/*.ejs','lib/**/*.js','routes/**/*.js','config/**/*.js']
};
browserSync(config);
gulp.watch('./public/js/**/*.js',['js'],browserSync.reload());
gulp.watch('./public/js/**/*.jsx',['react'],browserSync.reload());
gulp.watch('./public/coffee/**/*.coffee',['coffee'],browserSync.reload());
gulp.watch('./public/sass/**/*.scss',['sass'],browserSync.reload());
gulp.watch('./public/stylesheets/**/*.less',['less'],browserSync.reload());
});
gulp.task('default',['shell','serve'],function(){
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。