1 Star 0 Fork 0

ljq199612/theme-space

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gulpfile.js 2.53 KB
一键复制 编辑 原始数据 按行查看 历史
ljq 提交于 2020-06-09 15:07 . first commit
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
browserSync = require('browser-sync'),
stylus = require('gulp-stylus'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
jeet = require('jeet'),
rupture = require('rupture'),
koutoSwiss = require('kouto-swiss'),
prefixer = require('autoprefixer-stylus'),
imagemin = require('gulp-imagemin'),
cp = require('child_process');
var messages = {
jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build'
};
var jekyllCommand = (/^win/.test(process.platform)) ? 'jekyll.bat' : 'jekyll';
/**
* Build the Jekyll Site
*/
gulp.task('jekyll-build', function (done) {
browserSync.notify(messages.jekyllBuild);
return cp.spawn(jekyllCommand, ['build'], {stdio: 'inherit'})
.on('close', done);
});
/**
* Rebuild Jekyll & do page reload
*/
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
browserSync.reload();
});
/**
* Wait for jekyll-build, then launch the Server
*/
gulp.task('browser-sync', ['jekyll-build'], function() {
browserSync({
server: {
baseDir: '_site'
}
});
});
/**
* Stylus task
*/
gulp.task('stylus', function(){
gulp.src('src/styl/main.styl')
.pipe(plumber())
.pipe(stylus({
use:[koutoSwiss(), prefixer(), jeet(),rupture()],
compress: true
}))
.pipe(gulp.dest('_site/assets/css/'))
.pipe(browserSync.reload({stream:true}))
.pipe(gulp.dest('assets/css'));
});
/**
* Javascript Task
*/
gulp.task('js', function(){
return gulp.src('src/js/**/*.js')
.pipe(plumber())
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(gulp.dest('assets/js/'))
.pipe(browserSync.reload({stream:true}))
.pipe(gulp.dest('_site/assets/js/'));
});
/**
* Imagemin Task
*/
gulp.task('imagemin', function() {
return gulp.src('src/img/**/*.{jpg,png,gif}')
.pipe(plumber())
.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(gulp.dest('assets/img/'));
});
/**
* Watch stylus files for changes & recompile
* Watch html/md files, run jekyll & reload BrowserSync
*/
gulp.task('watch', function () {
gulp.watch('src/styl/**/*.styl', ['stylus']);
gulp.watch('src/js/**/*.js', ['js']);
gulp.watch('src/img/**/*.{jpg,png,gif}', ['imagemin']);
gulp.watch(['*.html', '_includes/*.html', '_layouts/*.html', '_posts/*'], ['jekyll-rebuild']);
});
/**
* Default task, running just `gulp` will compile the stylus,
* compile the jekyll site, launch BrowserSync & watch files.
*/
gulp.task('default', ['js', 'stylus', 'browser-sync', 'watch']);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
CSS
1
https://gitee.com/ljq199612/theme-space.git
git@gitee.com:ljq199612/theme-space.git
ljq199612
theme-space
theme-space
master

搜索帮助