Using Gulp to Compile Sass and minify vendor css

前端 未结 3 1220
慢半拍i
慢半拍i 2021-01-31 08:26

Getting to grips with Gulp and have a question.

So I have a gulp CSS task like the below which works just fine:

var sassDir = \'app/scss\';
var targetCss         


        
3条回答
  •  无人共我
    2021-01-31 08:57

    i found this recently gulp-cssjoin this allows you to replace imports with inline css

    the scss

    @import '../../bower_components/angular/angular-csp.css';
    

    the gulp task

    var gulp = require('gulp'),
        gutil = require('gulp-util'),
        sass = require('gulp-ruby-sass'),
        cssjoin = require('gulp-cssjoin'),
        csscomb = require('gulp-csscomb');
    
    gulp.task('sass',['images'], function() {
      return gulp.src('src/sass/*.{sass,scss}')
        .pipe(sass({
          compass: true,
          bundleExec: true,
          sourcemap: true,
          sourcemapPath: '../src/sass'
        }))
        .on('error',gutil.log.bind(gutil, 'Sass Error'))
        .pipe(cssjoin({
          paths: ['./src/sass']
        }))
        .pipe(csscomb())
        .pipe(gulp.dest('build'));
    });
    

    the important part is the passing in of the paths

    .pipe(cssjoin({
      paths: ['./src/sass']
    }))
    

提交回复
热议问题