0

I'm trying to get gulp to compile my SASS files and output them to the same source dir however I haven't been able to get it to work properly, I've tried using the base option:

gulp.task('sass_modules', function() {
    return gulp.src('Application/modules/**/*.scss', {base: '.'})
    .pipe(sassInheritance({dir: 'Application/modules/'}))
    .pipe(sourcemaps.init())
    .pipe(sass().on('error', sass.logError))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest('./'));
});

With the above code, it just outputs to the app root dir, the current working directory, any ideas how I can get this to work? An example of how I want it to work is to have a Application/modules/frontend/static/css/main.scss file, and have that compiled to Application/modules/frontend/static/css/main.css and Application/modules/frontend/static/css/main.css.map.

1 Answers1

0

Using this directory structure

Application
 │
 ├─── gulpfile.js
 └─┬─ modules
   └─┬─ frontend
     └─┬─ static
       └─┬─ css
         └─── main.scss

gulpfile.js

var sourcemaps = require('gulp-sourcemaps');
var sass = require('gulp-sass');
    
var scssFiles = 'modules/**/*.scss';    
    
gulp.task('sass_modules', function() {
  return gulp.src(scssFiles)
  .pipe(sourcemaps.init())
  .pipe(sass()
    .on('error', sass.logError))
  .pipe(sourcemaps.write('./'))
  .pipe(gulp.dest('./'));
});
Calvin
  • 1,305
  • 8
  • 17