title: getting gulp-sass to work with clean-css
body: <p>I'm trying to minify a scss file using clean-css and get a useful sourceMap file.</p>
  
  <p>My current gulp-task is:</p>
  
  <pre><code>var gulp = require('gulp'),
      sourcemaps = require('gulp-sourcemaps'),
      sass = require('gulp-sass'),
      through = require('through2');
      CleanCSS = require('clean-css'),
      applySourceMap = require('vinyl-sourcemaps-apply');
  
  var minify = through.obj(
      function minify(file,encoding,callback) {
          // do normal plugin logic
          var result = new CleanCSS({sourceMap:file.sourceMap
              ,target: "./src"}).minify(file.contents.toString());
          console.log(file.sourceMap)
          file.contents = new Buffer(result.styles);
  
          // apply source map to the chain
          if (file.sourceMap) {
              applySourceMap(file, result.sourceMap.toString());
          }
          this.push(file);
          callback();
      }
  );
  
  gulp.task('style', [],function () {
    return gulp.src('./myfile.scss',{cwd: 'src'})
      .pipe(sourcemaps.init())
      .pipe(sass())
      .pipe(minify)
      .pipe(sourcemaps.write('../maps/style',{sourceRoot:'/source/src'}))
      .pipe(gulp.dest('./build/style/'))
  
  });
  </code></pre>
  
  <p>when I run this setup I get the following error:</p>
  
  <pre><code>Error: Source map to be applied is missing the "file" property
    at assertProperty (node_modules/vinyl-sourcemaps-apply/index.js:32:13)
    at applySourceMap (node_modules/vinyl-sourcemaps-apply/index.js:11:3)
    at DestroyableTransform.minify [as _transform] (/gulp/tasks/style.js:21:4)
    at DestroyableTransform.Transform._read (/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
    at DestroyableTransform.Writable.write (/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
    at Stream.ondata (stream.js:51:26)
    at Stream.emit (events.js:95:17)
    at queueData (/node_modules/gulp-sass/node_modules/map-stream/index.js:43:21)
    at next (/node_modules/gulp-sass/node_modules/map-stream/index.js:71:7)
    at /node_modules/gulp-sass/node_modules/map-stream/index.js:85:7
    at handleOutput (/node_modules/gulp-sass/index.js:100:3)
    at opts.success (/node_modules/gulp-sass/index.js:63:7)
    at options.success (/node_modules/gulp-sass/node_modules/node-sass/lib/index.js:164:7)
  </code></pre>
  
  <p>If I add a dummy file path (or remove the assertions at <code>node_modules/vinyl-sourcemaps-apply/index.js:32:13)</code>) the source maps are generated however it does not recognize the original files (I.E. the scss files that gulp-sass compiled) and instead all my sources are mapped to `<strong>stdin</strong>' virtual file.</p>
  
  <p>How can I get <code>clean-css</code> to recognize the location of the mapped sources processed by <code>gulp-sass</code>?</p>