tschaub / gulp-newer

Pass through newer source files only
https://npmjs.org/package/gulp-newer
226 stars 24 forks source link

Won't build scss partials. #20

Open hutber opened 9 years ago

hutber commented 9 years ago

I have yet to be able to get this working with partials, only multiple base scss files.

My setup:

Gulp

javascript var SRC = './stylesheets/*/.scss'; var DEST = './stylesheets'; gulp.task('sass', function() { return gulp.src(SRC) //.pipe(changed(DEST, { extension: '.css' })) .pipe(newer({ dest: DEST, ext: '.css' })) .pipe(plumber({ errorHandler: handleErrors })) .pipe(sourcemaps.init()) .pipe(sass({})) .pipe(sourcemaps.write('./')) .on('error', handleErrors) .pipe(gulp.dest(DEST)) });


``` SCSS````
main.scss
    ¬ tools
       ¬ _generic-tool.scss

Main.scss
     @import "tools/generic-tool";

Any saves made inside main.scss will compile a new css file. However any saves made in any partial, in this particular case any saves made inside of _generic-tool will not compile any css.

Windows 7 64-bit version gulp-newer 0.5.0

TimMensch commented 8 years ago

Look at the new "options.extra" feature. It will handle this case like so:

var SRC = './stylesheets/**/*.scss';
var DEST = './stylesheets';
gulp.task('sass', function() {
  return gulp.src(SRC)
    .pipe(newer({ dest: DEST, ext: '.css', extra:SRC }))
    .pipe(plumber({
        errorHandler: handleErrors
    }))
    .pipe(sourcemaps.init())
    .pipe(sass({}))
    .pipe(sourcemaps.write('./'))
    .on('error', handleErrors)
    .pipe(gulp.dest(DEST))
});

If any of the files that extra can see change, then it rebuilds all the files.

If I were doing this, I'd change the gulp.src to point to the one source file that includes the others (Main.scss in your example, or a small set of such source files). Otherwise it's building most of the scss files twice.

QJan84 commented 5 years ago

If any of the files that extra can see change, then it rebuilds all the files.

Is there a way that only the respective parent file is compiled?

TimMensch commented 5 years ago

Not using the "extra" mechanism, no. And given that SASS/SCSS files have complex include structures, you'd need something that understood SASS/SCSS syntax in order to accomplish that.

Something like sass --watch. Then just use Gulp to copy the css files to the proper destinations (if needed).