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
写于 2016-04-27
(注:最新版本gulp部分方法有变)
插件页面:http://gulpjs.com/plugins/,或者在npm搜索gulpplugin
npm
gulpplugin
taoboa NPM: http://npm.taobao.org/
js目录下包含了压缩和未压缩的JavaScript文件,现在我们想要创建一个任务来压缩还没有被压缩的文件,我们需要先匹配目录下所有的JavaScript文件,然后排除后缀为.min.js的文件:
gulp.src(['js/**/*.js', '!js/**/*.min.js'])
监听文件变化执行回调
// 当文件变化时执行任务数组中的任务build gulp.task('watch', function () { gulp.watch('templates/*.tmpl.html', ['build']); });
或者
// 当文件变化时执行回调函数,包含事件对象event gulp.watch('templates/*.tmpl.html', function (event) { console.log('Event type: ' + event.type); // added, changed, or deleted console.log('Event path: ' + event.path); // The path of the modified file });
gulp.watch()返回一个watcher对象,watcher可以监听事件,或向watch中添加文件。
gulp.watch()
watcher
watch
// 监听change事件 var watcher = gulp.watch('templates/*.tmpl.html', ['build']); watcher.on('change', function (event) { console.log('Event type: ' + event.type); // added, changed, or deleted console.log('Event path: ' + event.path); // The path of the modified file });
可监听事件
Watcher对象一些可以调用的方法:
Watcher
参数:任务名称,执行函数
gulp.task('greet', function () { console.log('Hello world!'); }); // 运行 gulp greet // Hello world
// 运行gulp build时,同时无序执行css、js、imgs三个任务 gulp.task('build', ['css', 'js', 'imgs']);
// 运行gulp css时,先执行greet任务,结束后执行回调函数 gulp.task('css', ['greet'], function () { // Deal with CSS here });
// 运行gulp时,执行default任务 gulp.task('default', function () { // Your default task });
gulp.task('copy', function () { gulp.src('src/fonts/**/*') .pipe(gulp.dest('dist/fonts/')) })
The text was updated successfully, but these errors were encountered:
No branches or pull requests
写于 2016-04-27
(注:最新版本gulp部分方法有变)
gulp
插件页面:http://gulpjs.com/plugins/,或者在
npm
搜索gulpplugin
taoboa NPM: http://npm.taobao.org/
安装
GULP.SRC(glob)
js目录下包含了压缩和未压缩的JavaScript文件,现在我们想要创建一个任务来压缩还没有被压缩的文件,我们需要先匹配目录下所有的JavaScript文件,然后排除后缀为.min.js的文件:
GULP.WATCH(glob)
监听文件变化执行回调
或者
gulp.watch()
返回一个watcher
对象,watcher
可以监听事件,或向watch
中添加文件。可监听事件
Watcher
对象一些可以调用的方法:定义任务
参数:任务名称,执行函数
并行任务
串行任务
默认任务
复制文件
The text was updated successfully, but these errors were encountered: