1 Star 0 Fork 0

钟振升/fwxperson

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gulpfile.js 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
钟振升 提交于 2021-04-18 09:50 . 1
var gulp = require('gulp');
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var cache = require('gulp-cache');
var cp = require('child_process');
var browserSync = require('browser-sync');
var jekyll = process.platform === 'win32' ? 'jekyll.bat' : 'jekyll';
// Build the Jekyll Site
gulp.task('jekyll-build', function (done) {
return cp.spawn( jekyll , ['build'], {stdio: 'inherit'})
.on('close', done);
});
// Rebuild Jekyll and page reload
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
browserSync.reload();
});
// Wait for jekyll-build, then launch the Server
gulp.task('browser-sync', ['sass', 'img', 'jekyll-build'], function() {
browserSync({
server: {
baseDir: '_site'
},
notify: false
});
});
// Compile files
gulp.task('sass', function () {
return gulp.src('assets/css/scss/main.scss')
.pipe(sass({
outputStyle: 'expanded',
onError: browserSync.notify
}))
.pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(gulp.dest('_site/assets/css'))
.pipe(browserSync.reload({stream:true}))
.pipe(gulp.dest('assets/css'));
});
// Compression images
gulp.task('img', function() {
return gulp.src('assets/img/**/*')
.pipe(cache(imagemin({
interlaced: true,
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
})))
.pipe(gulp.dest('_site/assets/img'))
.pipe(browserSync.reload({stream:true}));
});
// Watch scss, html, img files
gulp.task('watch', function () {
gulp.watch('assets/css/scss/**/*.scss', ['sass']);
gulp.watch('assets/js/**/*.js', ['jekyll-rebuild']);
gulp.watch('assets/img/**/*', ['img']);
gulp.watch(['*.html', '_layouts/*.html', '_includes/*.html', '_pages/*.html', '_posts/*'], ['jekyll-rebuild']);
});
// Default task
gulp.task('default', ['browser-sync', 'watch']);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Michael07/fwxperson.git
git@gitee.com:Michael07/fwxperson.git
Michael07
fwxperson
fwxperson
master

搜索帮助