0

I'm trying to pipe my compiled .css file to same directory as its original .scss one

gulp.task('sass', function() {
  return gulp.src([
    appDir + '/*.scss',
    appDir + '/**/*.scss'
  ])
  .pipe(sass())
  .pipe(gulp.dest(..));
});

I can't figure out how to set gulp.dest to be the same as the original .scss file so I have both this and .css file in the same folder.

Ilja
  • 44,142
  • 92
  • 275
  • 498
  • **Tip:** It's only necessary to have `appDir + '/**/*.scss'` in your `gulp.src`. That will pick up any scss file in the `appDir` directory, so `appDir + '/*.scss'` is unnecessary. – Colin Marshall Jan 13 '16 at 03:35

2 Answers2

1

you can use a custom function and set your own path for each file.

var path = require('path');

gulp
    .src('path/to/files')
    .pipe(YourOperation({...}))
    .pipe(gulp.dest(function(file) {
        return path.dirname(file.path); // <- is here
    }))
;
Think Big
  • 1,021
  • 14
  • 24
0

No, you can set the destination to wherever you want.

For instance, you can have a different destination for each release, Staging, UAT, Prod

check the gulp-dest documentation for examples, if you combine your task with gulp-yargs for instance, you can set different attributes to handle the destination, versions...

Example:

gulp.task('scss', function () {
    var appDir = './public/css';
    return gulp.src([
        appDir + '/*.scss',
        appDir + '/**/*.scss'
    ])
    .pipe(sass())
    .pipe(gulp.dest('./build/css/'));
});
rmjoia
  • 962
  • 12
  • 21