首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在sass中使用gulp use-ref

如何在sass中使用gulp use-ref
EN

Stack Overflow用户
提问于 2015-10-30 19:57:09
回答 1查看 615关注 0票数 3

在这个项目中,我有:

代码语言:javascript
复制
<!-- build:css css/error.css -->
<link rel="stylesheet" href="src/assets/styles/_bootstrap.scss" type="text/css" media="all">
<!-- endbuild -->

以及gulp文件:

代码语言:javascript
复制
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。

EN

回答 1

Stack Overflow用户

发布于 2016-10-17 22:31:11

在我的项目中,我使用gulp-rename来做这样的事情。

代码语言:javascript
复制
.pipe(rename({ suffix: '.min' }))

安装gulp-rename

在你的任务中这样做:

代码语言:javascript
复制
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'));
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33435448

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档