We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
比如在命令行中传入参数
gulp --page app.html
目前(2015-08-13 16:44:17)可以使用gulp.env.page获取到app.html。但是会提示
gulp.env has been deprecated. Use your own CLI parser instead. We recommend usin g yargs or minimist.
官方推荐的方法是使用yargs或者minimist等来实现。
如:yargs
npm install yargs -g
安装成功后,在gulpfile.js里面:
var argv = require('yargs').argv; console.log(argv.page)
便可读取到传入的app.html
这时在之前的gulpfile.js里面便可以这样
var gulp = require('gulp'), livereload = require('gulp-livereload'), argv = require('yargs').argv; var path = { js:'./js/*.js', css:'./css/*.css', html:'*.html' }; function obj2array(obj){ var arr = []; for(var i in obj){ arr.push(obj[i]) } return arr; } gulp.task('watch',function(){ gulp.watch(obj2array(path),['livereload']); }) gulp.task('livereload',function(){ livereload.listen(); livereload.reload(argv.page || 'index.html'); }) gulp.task('default',['watch'])
The text was updated successfully, but these errors were encountered:
No branches or pull requests
使用gulp-livereload自动刷新页面的时候,默认是刷新index.html。想刷新其他页面时,可以在命令行传入参数
比如在命令行中传入参数
目前(2015-08-13 16:44:17)可以使用gulp.env.page获取到app.html。但是会提示
官方推荐的方法是使用yargs或者minimist等来实现。
如:yargs
安装成功后,在gulpfile.js里面:
便可读取到传入的app.html
这时在之前的gulpfile.js里面便可以这样
The text was updated successfully, but these errors were encountered: