按照gulp-express的说明,我简单地写了app.js,gulpfile.js,和index.html三个页面
###app.js const express = require(‘express’);
const app = module.exports.app = exports.app = express();
app.use(express.static(‘public’)); app.get(’/’, (req,res,next) => { res.render(‘index.html’) }) app.listen(3000, () => { console.log(‘开启服务器’); });
###gulpfile.js const gulp = require(‘gulp’); const server = require(‘gulp-express’); let serverFile = path.resolve(process.cwd(), ‘app.js’);
gulp.task(‘server’, () => { server.run([serverFile]); gulp.watch([‘public/index.html’], server.notify); gulp.watch([serverFile], [server.run]); });
我修改app.js,可以做到重启,可是我修改index.html,浏览器却不能刷新,有大神用过gulp-express吗,望指点一二