代码拉取完成,页面将自动刷新
同步操作将从 hswuhao/BearAdmin 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/**
* Created by Administrator on 2017/5/16.
*/
var gulp = require('gulp'),
rename = require('gulp-rename'),
notify = require('gulp-notify'),
sass = require('gulp-sass'),
minifyCss = require('gulp-minify-css'),
plumber = require('gulp-plumber'),
babel = require('gulp-babel'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
clearnHtml = require("gulp-cleanhtml"),
imagemin = require('gulp-imagemin'),
copy = require('gulp-contrib-copy'),
browserSync = require('browser-sync').create(),
reload = browserSync.reload;
// 定义源代码的目录和编译压缩后的目录
var src = 'resources/admin',
dist = 'public/static/admin';
// 编译全部scss 并压缩
gulp.task('css', function () {
gulp.src(src + '/**/*.scss')
.pipe(sass())
.pipe(minifyCss())
.pipe(gulp.dest(dist))
})
// 编译全部js 并压缩
/*gulp.task('js', function () {
gulp.src(src + '/!**!/!*.js')
.pipe(plumber())
.pipe(babel({
presets: ['es2015']
}))
.pipe(uglify())
.pipe(gulp.dest(dist));
});*/
gulp.task('js', function() {
return gulp.src(
[src + '/plugins/jQuery/jquery-2.2.3.min.js',
src + '/bootstrap/js/bootstrap.min.js',
src + '/js/app.min.js',
src + '/js/admin.js'])
.pipe(concat('app.js'))
.pipe(uglify())
.pipe(gulp.dest(dist+'/js'))
.pipe(notify({ message: 'js task ok' }));
});
//这个地方还未修改
/*gulp.task("js", function () {
// 把1.js和2.js合并压缩为main.js,输出到dest/js目录下
gulp.src([src + '/plugins/jQuery/jquery-2.2.3.min.js',src + '/bootstrap/js/bootstrap.min.js',src + '/js/app.min.js', src + '/js/admin.js']).pipe(concat('app1.min.js')).pipe(uglify()).pipe(gulp.dest(dist+'/js'));
})*/
// 压缩全部html
gulp.task('html', function () {
gulp.src(src + '/**/*.+(html|tpl)')
.pipe(clearnHtml())
.pipe(gulp.dest(dist));
});
// 压缩全部image
gulp.task('image', function () {
gulp.src([src + '/**/*.+(jpg|jpeg|png|gif|bmp)'])
.pipe(imagemin())
.pipe(gulp.dest(dist));
});
// 其他不编译的文件直接copy
gulp.task('copy', function () {
gulp.src(src + '/**/*.!(jpg|jpeg|png|gif|bmp|scss|js|html|tpl)')
.pipe(copy())
.pipe(gulp.dest(dist));
});
// 自动刷新
gulp.task('server', function () {
browserSync.init({
proxy: "localhost:91", // 指定代理url
notify: false // 刷新不弹出提示
});
// 监听scss文件编译
gulp.watch(src + '/**/*.scss', ['css']);
// 监听其他不编译的文件 有变化直接copy
gulp.watch(src + '/**/*.!(jpg|jpeg|png|gif|bmp|scss|js|html)', ['copy']);
// 监听html文件变化后刷新页面
gulp.watch(src + "/**/*.js", ['js']).on("change", reload);
// 监听html文件变化后刷新页面
gulp.watch(src + "/**/*.+(html|tpl)", ['html']).on("change", reload);
// 监听css文件变化后刷新页面
gulp.watch(dist + "/**/*.css").on("change", reload);
});
// 监听事件
gulp.task('default', ['css', 'js', 'image', 'html', 'copy', 'server'])
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。