【问题标题】:Gulp-sass compressed style doesn't seem to work for me when trying to compile and output sourcemaps尝试编译和输出源映射时,Gulp-sass 压缩样式似乎对我不起作用
【发布时间】:2020-07-26 23:34:51
【问题描述】:

我正在尝试让我的 gulp 管道为网站工作,但它似乎不想压缩 scss,我已将所有 sass 编译到单个 css 文件中,但文件未压缩。我尝试更改 node_modules 下的原始文件,认为它可能会刷新缓存或其他东西,但看起来这种风格不起作用或者它不像我认为的那样。

function css() {
   return gulp
       .src('./scss/*.scss')
       .pipe(sourcemaps.init())
       .pipe(sass({ style: 'compressed' }).on('error', sass.logError))
       .pipe(sourcemaps.write('./'))
       .pipe(gulp.dest('./css'));
}

谢谢

【问题讨论】:

    标签: css sass gulp


    【解决方案1】:

    如此接近,您需要将style 更改为outputStyle,它应该可以工作。

    See examples in the options section for gulp-sass.

    function css() {
       return gulp
           .src('./scss/*.scss')
           .pipe(sourcemaps.init())
           .pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
           .pipe(sourcemaps.write('./'))
           .pipe(gulp.dest('./css'));
    }
    

    【讨论】:

      【解决方案2】:

      对于那些对 outputStyle的可能值感兴趣的人

      • 嵌套
      • 已扩展
      • 紧凑
      • 压缩

      f.e.使用 Gulp 你可以像 .pipe(sass(outputStyle: 'expanded'))

      一样使用它

      (来源https://inchoo.net/dev-talk/tools/sass-output-styles/

      【讨论】:

        猜你喜欢
        • 2017-02-06
        • 2015-01-09
        • 2014-11-06
        • 2017-03-24
        • 1970-01-01
        • 1970-01-01
        • 2014-04-30
        • 2013-11-01
        相关资源
        最近更新 更多