radist2s / gulp-less-sourcemap

A LESS plugin for Gulp with sourcemap support
10 stars 5 forks source link

Files are all dumped into a single location (not structured / source) #4

Open jadrake75 opened 8 years ago

jadrake75 commented 8 years ago

Maybe I am missing a configuration here, but I have a file structure where my files are structured under src like this

src/
   components/
      comp1.less
      comp2.less
   views/
       view1.less
       subview/
           subview1.less

This is a gross simplification, but you get the picture.

When I used the regular gulp-less and gulp-sourcemaps plugins standalone

return gulp.src(paths.appLess) // src/**/*.less
        .pipe(sourcemaps.init())
        .pipe(less({
            paths: [
                paths.baseDir, // root project folder
            ],
            sourceMap: {
                sourceMapRootpath:paths.appLess // src/**/*.less
            }
        }).on('error', function(error) {  console.log(error);}))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(paths.lessOut));  // resources/styles

I get what I want (files under resources/styles in the structure of src)

If I try the combined plugin:

return gulp.src(paths.appLess)
    .pipe(changed(paths.less, {extension: '.css'}))
        .pipe(less({
            paths: [
                paths.baseDir
            ],
            sourceMap: {
                sourceMapFileInline: false,
                sourceMapRootpath: paths.appLess,
                debug: true
            }
        }).on('error', function (error) {
            gutil.log(gutil.colors.red(error.message));
            this.emit('end');
        })
    )
        .pipe(gulp.dest(paths.lessOut))

Everything is flattened in 'resources/styles' without the subfolders like views, components etc.

Am I just missing something in the settings, or is this a flaw/issue with the implementation?

magicdawn commented 8 years ago

here is the reason: https://github.com/radist2s/gulp-less-sourcemap/blob/master/index.js#L65-L67

constructing a new Vinyl File but lose file.base & file.path info

magicdawn commented 8 years ago

it should be what gulp-less have done:
https://github.com/plus3network/gulp-less/blob/v3.0.5/index.js#L38-L39

just override contents & path( .less -> .css)

radist2s commented 8 years ago

Thank you for the report. I updated the module, do you can try it and then publish a report?

UPD: Ping for @jadrake75