text: 'use strict';
  
  var gulp = require('gulp');
  
  var paths = gulp.paths;
  
  var $ = require('gulp-load-plugins')();
  
  gulp.task('styles', function () {
  
    var sassOptions = {
      style: 'expanded'
    };
  
    var injectFiles = gulp.src([
      paths.src + '/{app,components}/**/*.scss',
      '!' + paths.src + '/app/index.scss',
      '!' + paths.src + '/app/vendor.scss'
    ], { read: false });
  
    var injectOptions = {
      transform: function(filePath) {
        filePath = filePath.replace(paths.src + '/app/', '');
        filePath = filePath.replace(paths.src + '/components/', '../components/');
        return '@import \'' + filePath + '\';';
      },
      starttag: '// injector',
      endtag: '// endinjector',
      addRootSlash: false
    };
  
    var indexFilter = $.filter('index.scss');
  
    return gulp.src([
      paths.src + '/app/index.scss',
      paths.src + '/app/vendor.scss'
    ])
      .pipe(indexFilter)
      .pipe($.inject(injectFiles, injectOptions))
      .pipe(indexFilter.restore())
      .pipe($.rubySass(sassOptions)
        .on('error', function (err) {
          console.error('Error!', err.message);
        })
      )
  
    .pipe($.autoprefixer())
      .on('error', function handleError(err) {
        console.error(err.toString());
        this.emit('end');
      })
      .pipe(gulp.dest(paths.tmp + '/serve/app/'));
  });
  