3

在项目中我有:

<!-- build:css css/error.css -->
<link rel="stylesheet" href="src/assets/styles/_bootstrap.scss" type="text/css" media="all">
<!-- endbuild -->

和吞咽文件:

gulp.task('test', function () {
    return gulp.src('path_to_html')
        .pipe(gulp.src('path_to_styles'))
        .pipe(gulpif('path_to_styles', sass()))
        .pipe('path_to_styles'.restore())
        .pipe(useref())
        .pipe(gulp.dest('target_folder'));
});

如何首先将 .scss 转换为 .css,然后使用 use-ref。

4

1 回答 1

0

在我的项目中,我曾经gulp-rename做过类似的事情。

.pipe(rename({ suffix: '.min' }))

安装gulp-rename

在你的任务中这样做:

gulp.task('test', function () {
    return gulp.src('path_to_html')
        .pipe(gulp.src('path_to_styles'))
        .pipe(gulpif('path_to_styles', sass()))
        .pipe('path_to_styles'.restore())
        .pipe(rename({
            extname: ".css"
        }))
        .pipe(useref())
        .pipe(gulp.dest('target_folder'));
});
于 2016-10-17T14:31:10.543 回答