title: How do I create a sourcemap back to the original .less files from a minified CSS file?
body: <p>I am working with Gulp.js, and I am stumped trying to get gulp-sourcemaps to point all the way back at the original less files, after I do a minification step.</p>
  
  <p>Since gulp-minify-css doesn't support sourcemaps, I am using postcss &amp; csswring.</p>
  
  <p>Ideally, I'd like to end up with:</p>
  
  <ul>
  <li>ss.css (unminified)</li>
  <li>ss.css.map (pointing from ss.css back to original .less files)</li>
  <li>ss.min.css (minified)</li>
  <li>ss.min.css.map (pointing from ss.min.css back to original .less files)</li>
  </ul>
  
  <p>For now, I've stopped trying to output both the minified and non-minified versions, but even getting the minified version to point back to the original .less files doesn't seem to work.</p>
  
  <p>Without doing a minification step, my .map file works great and looks like this:</p>
  
  <pre><code>{"version":3,"sources":["ss.less"],"names":[],"mappings":";AAEA;...
  </code></pre>
  
  <p>When I do the minification step, it changes the map to point the minified file back at the compiled CSS, not the original Less files:</p>
  
  <pre><code>{"version":3,"sources":["ss-min.css"],"names":[],"mappings":";AAEA;...
  </code></pre>
  
  <p>Here's my gulpfile.js:</p>
  
  <pre><code>var csswring = require('csswring'),
      gulp = require('gulp'),
      less = require('gulp-less'),
      path = require('path'),
      postcss = require('gulp-postcss'),
      rename = require('gulp-rename'),
      sourcemaps = require('gulp-sourcemaps');
  
  var sourceLess = path.join(__dirname, 'app', 'assets', 'less');
  var targetCss = path.join(__dirname, 'app', 'assets', 'css');
  
  // Compile Less to CSS and then Minify, Include Sourcemaps
  gulp.task('less-and-minify-css', function () {
      return gulp.src(lessFiles)
          .pipe(sourcemaps.init())
          .pipe(less())
          .pipe(rename({suffix: "-min"}))
          .pipe(postcss([csswring]))
          .pipe(sourcemaps.write('.'))
          .pipe(gulp.dest(targetCss));
  });
  </code></pre>
  
  <p>As always, any thoughts appreciated!</p>
  
  <p>I have experimented with using a filter to only rename the generated .css files and nothing else, but that doesn't seem to fix the core issue.</p>