代码拉取完成,页面将自动刷新
var gulp = require('gulp'),
minifycss = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
del = require('del'),
rev = require('gulp-rev'),
minifyhtml = require('gulp-minify-html'),
inject = require('gulp-inject'),
manifest = require('gulp-manifest');
// move
gulp.task('move', function() {
return gulp.src(
['js/**/*jquery*js', 'js/**/*bootstrap*js', 'images/**/*', 'css/**/*bootstrap*', 'index.html'], {
base: './'
}
).pipe(gulp.dest('dist'));
});
// js
gulp.task('js', function() {
return gulp.src(['js/**/*', '!js/**/*jquery*js', '!js/**/*bootstrap*js'])
.pipe(concat('user.js'))
.pipe(uglify({
compress: {
drop_console: true
}
}))
.pipe(rev())
.pipe(gulp.dest('dist/js'));
});
// css
gulp.task('css', function() {
return gulp.src(['css/**/*', '!css/**/*bootstrap*css'])
.pipe(concat('user.css'))
.pipe(minifycss())
.pipe(rev())
.pipe(gulp.dest('dist/css'));
});
// index.html
gulp.task('index', ['move', 'js', 'css'], function() {
var sources = gulp.src(['dist/js/**/*.js', '!dist/js/**/*jquery*js', '!dist/js/**/*bootstrap*js', 'dist/css/**/*.css', '!dist/css/**/*bootstrap*css'], {
read: false
});
return gulp.src('dist/index.html')
.pipe(inject(sources, {
relative: true
}))
.pipe(minifyhtml())
.pipe(gulp.dest('dist'));
});
//manifest
gulp.task('manifest', ['index'], function() {
gulp.src(['dist/**/*', '!dist/index.html'])
.pipe(
manifest({
hash: true,
preferOnline: true,
network: ['http://*', 'https://*', '*'],
filename: 'app.manifest',
exclude: ['app.manifest', 'CNAME']
})
).pipe(gulp.dest('dist'));
});
// Clean
gulp.task('clean', function(cb) {
del(['dist/**/*', '!dist/CNAME'], cb);
});
// Default task
gulp.task('default', ['clean'], function() {
gulp.start('manifest');
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。