gulp工程化工具
gulpfile.js
var gulp = require('gulp'); var rename = require('gulp-rename') var pump = require('pump'); var connect = require('gulp-connect'); //ftl转html gulp.task('ftl-html',function(cb){ pump([ gulp.src('WEB-INF/page/Wechat/*.ftl'), rename({extname:'.html'}), gulp.dest('./html/Wechat') ]) }) //html转ftl gulp.task('html-ftl',function(cb){ pump([ gulp.src('./html/Wechat'), rename({extname:'.ftl'}), gulp.dest('WEB-INF/page/Wechat') ]) }) // webserver livereload web服务器 gulp.task('webserver', function() { connect.server({ root:'./', port:9000, livereload:true }); }); gulp.task('html', function () { gulp.src('**/**/*.html') .pipe(connect.reload()); }); gulp.task('watch',function(){ gulp.watch(['./*html'],['html']) }) gulp.task('default',['webserver','watch'])
package.json
{ "name": "webapp", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "gulp": "^3.9.1", "gulp-connect": "^5.0.0", "gulp-rename": "^1.2.2", "pump": "^1.0.2" } }
参考文章http://www.gulpjs.com.cn/docs/api/
你要觉得这篇文章比较好,记得点推荐!