nixonchris / gulp-transform-selectors

MIT License
1 stars 1 forks source link

Plugin is not compatible with gulp-sourcemaps #1

Open RadValentin opened 10 years ago

RadValentin commented 10 years ago

I'm trying to prefix my selectors with this plugin and have sourcemaps generated by gulp-sourcemaps but the problem is that your plugin is changing the way my css is written by removing whitespaces. Someting like this (with splitOnCommas: true):

h1,
h2,
h3 {
 ...
}

is rendered out as

.prefix h1, .prefix h2, .prefix h3 {
   ...
}

This in turn messes things up because the sourcemap plugin doesn't account for this change. So can you please add support for gulp-sourcemaps? Info on how to do this can be found here.

RadValentin commented 10 years ago

I've been thinking about this and maybe you could add sourcemap support another way. Postcss supports sourcemaps maybe you could add in an extra parameter that would enable sourcemap preservation/generation. Then you'd call the plugin like this:

var transformSelectors = require("gulp-transform-selectors");

gulp.src("./src/*.css")
    .pipe(transformSelectors(function (selector) {
        return '.ie8 ' + selector;
    }, {
        splitOnCommas: true,
        postcss: {
          map: true,
          from: 'style.css',
          to: 'style.css'
        }
    }))
    .pipe(gulp.dest("./dist"));

What do you think?