在 gulpfile.js? 中启动 hexo 生成手表?
Start hexo to generate a watch in a gulpfile.js?
我有以下gulpfile.js
var gulp = require('gulp'),
browserSync = require('browser-sync'),
sass = require('gulp-sass'),
bower = require('gulp-bower'),
notify = require('gulp-notify'),
reload = browserSync.reload,
bs = require("browser-sync").create(),
Hexo = require('hexo'),
hexo = new Hexo(process.cwd(), {});
var src = {
scss: './scss/',
css: './source/css',
ejs: 'layout'
},
watchFiles = [
'./scss/*.scss',
'*/*.ejs'
];
// Static Server + watching scss/html files
gulp.task('serve', ['sass:watch'], function() {
// init starts the server
bs.init(watchFiles, {
server: {
baseDir: "../../public"
},
logLevel: "debug"
});
hexo.init();
hexo.call('generate', {}, function(){
console.log('Started Hexo Server');
})
});
如何在 gulpfile 中的 watch 中启动 hexo?
gulpfile 的其余部分在这里:
https://github.com/chrisjlee/hexo-theme-zurb-foundation/blob/master/gulpfile.js
hexo索引文件在这里接受参数;但我无法弄清楚参数;
https://github.com/hexojs/hexo/blob/master/lib/hexo/index.js
您可以在第二个参数中传递参数。例如:
hexo.init().then(function(){
return hexo.call('generate', {watch: true});
}).catch(function(err){
console.log(err);
});
我有以下gulpfile.js
var gulp = require('gulp'), browserSync = require('browser-sync'), sass = require('gulp-sass'), bower = require('gulp-bower'), notify = require('gulp-notify'), reload = browserSync.reload, bs = require("browser-sync").create(), Hexo = require('hexo'), hexo = new Hexo(process.cwd(), {}); var src = { scss: './scss/', css: './source/css', ejs: 'layout' }, watchFiles = [ './scss/*.scss', '*/*.ejs' ]; // Static Server + watching scss/html files gulp.task('serve', ['sass:watch'], function() { // init starts the server bs.init(watchFiles, { server: { baseDir: "../../public" }, logLevel: "debug" }); hexo.init(); hexo.call('generate', {}, function(){ console.log('Started Hexo Server'); }) });
如何在 gulpfile 中的 watch 中启动 hexo?
gulpfile 的其余部分在这里:
https://github.com/chrisjlee/hexo-theme-zurb-foundation/blob/master/gulpfile.js
hexo索引文件在这里接受参数;但我无法弄清楚参数;
https://github.com/hexojs/hexo/blob/master/lib/hexo/index.js
您可以在第二个参数中传递参数。例如:
hexo.init().then(function(){
return hexo.call('generate', {watch: true});
}).catch(function(err){
console.log(err);
});