我一直在修改GulpJS,并认为这是Grunt的下一步,但是在语法方面存在一些问题.
这是我的一节Gruntfile.js:
concat: {
ie: {
options: {
separator: "\n\n"
},
src: [
"bower_components/selectivizr/selectivizr.js",
"bower_components/respond/dest/respond.min.js",
"bower_components/REM-unit-polyfill/js/rem.js"
],
dest: "assets/js/build/ie.js"
},
dist: {
options: {
separator: "\n\n"
},
src: [
// Foundation Vendor
"bower_components/foundation/js/vendor/fastclick.js",
"bower_components/foundation/js/vendor/placeholder.js",
// Foundation Core
"bower_components/foundation/js/foundation/foundation.js",
"bower_components/foundation/js/foundation/foundation.abide.js",
"bower_components/foundation/js/foundation/foundation.accordion.js",
"bower_components/foundation/js/foundation/foundation.alert.js",
"bower_components/foundation/js/foundation/foundation.clearing.js",
"bower_components/foundation/js/foundation/foundation.dropdown.js",
"bower_components/foundation/js/foundation/foundation.interchange.js",
"bower_components/foundation/js/foundation/foundation.joyride.js",
"bower_components/foundation/js/foundation/foundation.magellan.js",
"bower_components/foundation/js/foundation/foundation.offcanvas.js",
"bower_components/foundation/js/foundation/foundation.orbit.js",
"bower_components/foundation/js/foundation/foundation.reveal.js",
"bower_components/foundation/js/foundation/foundation.tab.js",
"bower_components/foundation/js/foundation/foundation.tooltip.js",
"bower_components/foundation/js/foundation/foundation.topbar.js",
// Custom Vendor
// Project
"assets/js/src/_init.js"
],
dest: "assets/js/build/scripts.js"
}
}
Run Code Online (Sandbox Code Playgroud)
所以你可以看到,我正在指定特定的文件(因为我不想像你通常看到的那样拉入整个目录),这看起来很简单.我发现Gulp的所有内容似乎都遵循正则表达式格式:
gulp.task('scripts', function() {
return gulp.src("assets/js/src/_init.js")
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('main.js'))
.pipe(gulp.dest('assets/js/build'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(livereload(server))
.pipe(gulp.dest('assets/js/build'))
.pipe(notify({ message: 'Scripts task complete' }));
});
Run Code Online (Sandbox Code Playgroud)
但是将逗号分隔的列表放入该src部分不起作用 - 我们如何将一组文件传递给该方法?
看起来我可以在一个中使用多个流来分离我的IE特定脚本,如下所示:
gulp.task('test', function(cb) {
return es.concat(
gulp.src('bootstrap/js/*.js')
.pipe(gulp.dest('public/bootstrap')),
gulp.src('jquery.cookie/jquery.cookie.js')
.pipe(gulp.dest('public/jquery'))
);
});
Run Code Online (Sandbox Code Playgroud)
但是如果这是正确的那么快速评论也会很棒.谢谢!
Ove*_*ous 35
从文档:
水珠
输入:
String或Array全球或全球阅读.
换句话说,传入一个字符串数组,如:
gulp.src(['file1.js', 'file2.js']).pipe(...)
// ^ ^
// '-------- Array -------'
Run Code Online (Sandbox Code Playgroud)
请注意,这与Grunt的格式完全相同.它是一组globs,而不是以逗号分隔的列表.
| 归档时间: |
|
| 查看次数: |
9805 次 |
| 最近记录: |