onedesign / generator-one-base

A foundation for One Design Company projects on the web.
Other
1 stars 1 forks source link

Sass Sourcemaps #91

Open MikeMcChillin opened 7 years ago

MikeMcChillin commented 7 years ago

I wanna add sass sourcemaps. Only thing I'm not sure of is how it'd work with production - we'd def want to not include them there.

Adding to our styles.js could look something like this: var sourcemaps = require('gulp-sourcemaps');

module.exports = gulp.task('styles', function() {
  var postCssProcessors = [
    importCss(),
    autoprefixer({ browsers: ['last 2 versions'] })
  ];

  return gulp.src([
    config.paths.styleSrc + 'main.scss',
  ])
  .pipe(sourcemaps.init()) // init
  .pipe(cssGlobbing({
    extensions: ['.scss']
  }))
  .pipe(sass({
    outputStyle: 'compressed',
    includePaths: ['./node_modules']
  }).on('error', function(error) {
    global.browserSync.notify(error.message, 30000);
    sass.logError.call(this, error);
  }))
  .pipe(postcss(postCssProcessors, {}))
  .pipe(pixrem({ rootValue: '10px' }))
  .pipe(sourcemaps.write()) // and write
  .pipe(gulp.dest(config.paths.styleDist))
  .pipe(global.browserSync.reload({ stream: true }));
});

I think we'd just prob need like gulp-if to check for production / build or whatever.