Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using Less Autoprefix plugin breaks sourcemaps (sources property) #126

Closed
bassjobsen opened this issue Jan 23, 2015 · 3 comments
Closed

Comments

@bassjobsen
Copy link

When i using the following gulpfile.js:

var gulp = require('gulp'),
    less = require('gulp-less'),
    sourcemaps = require('gulp-sourcemaps');

var LessPluginAutoPrefix = require('less-plugin-autoprefix'),
    autoprefix= new LessPluginAutoPrefix({browsers: ["last 2 versions"]});

gulp.task('default', function () {
  return gulp
 .src('./less/**/*.less')
 .pipe(sourcemaps.init())
  .pipe(less({
    plugins: [autoprefixer]
   }))
  .pipe(sourcemaps.write('./'))
  .pipe(gulp.dest('./css'));
});

The source map got a invalid second value for the sources property ("../<input css 1>").

The sourcemap code looks like that shown below:

{"version":3,"sources":["t.less","../<input css 1>"],"names":[],"mappings":

When using autoprefixer = require('gulp-autoprefixer'); with .pipe(autoprefixer()) instead of the plugin, the generated sourcemap is correct.

To verify if the problem is not related to the Less Autoprefix plugin itself, i have compiled the Less code with the command line Less compiler and the autoprefix plugin by running: lessc less/t.less css/t.css --autoprefix --source-map --source-map-less-inline. Also the preceding command gives an sourcemap as expected ({"version":3,"sources":["../less/t.less","t.css"],"names":[])

@yocontra
Copy link
Member

No idea - less should be dealing with the sourcemaps of plugins before it even hands data back to us. Will take some debugging.

@bassjobsen
Copy link
Author

I understand now your are using inline sourcemap. So i tested lessc less/t.less --autoprefix --source-map --source-map-less-inline --source-map-map-inline which generates a wrong sourcemap. So the issue is related to the Less plugin (or Less) indeed.

@yocontra
Copy link
Member

Reopen on the relevant repo and link to this issue so people can track the progress

bassjobsen added a commit to bassjobsen/gulp-less that referenced this issue Jan 24, 2015
When searching for a solution for gulp-community#126 i wondered why using Less with sourceMapFileInline (setting the SourceContent property of the source map with source files contents).

Not using the sourceMapFileInline and using `result.map` directly gives me the same results after some testing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants