我是 gulp 的新手,我正在尝试连接和缩小我的 JS 和 CSS 文件。我用的是翡翠。
gulpfile.js
gulp.task('jade2html', function() {
return gulp.src('app/*.jade')
.pipe(jade({pretty: true}))
.pipe(gulp.dest('dist'));
})
gulp.task('useref', function() {
return gulp.src('app/*.jade')
.pipe(useref())
.pipe(gulpIf('*.js', uglify()))
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulp.dest('dist'))
})
索引.jade
// build:css css/style.min.css
link(rel='stylesheet', href='/css/style.css')
link(rel='stylesheet', href='/css/print.css')
// endbuild
// build:js js/main.min.js
script(src='js/lib/a-library.js')
script(src='js/lib/another-lib.js')
script(src='js/main.js')
// endbuild
当我运行我的任务useref
然后我检查我的main.min.js
或style.min.css
文件是空的。所以,我错过了一些步骤?(当我不使用 Jade 而只使用 HTML 时,一切正常)。