ft/aurelia_project/tasks/process-css.js
2017-06-09 09:09:06 +01:00

33 lines
1.1 KiB
JavaScript

// changed to SASS+autoprefixer using this blog post: http://ilikekillnerds.com/2016/07/adding-postcssautoprefixer-aurelia-cli/
import gulp from 'gulp';
import sourcemaps from 'gulp-sourcemaps';
import project from '../aurelia.json';
import sass from 'gulp-sass';
import postcss from 'gulp-postcss';
import cssnano from 'gulp-cssnano';
import autoprefixer from 'autoprefixer';
import lintCSS from './lint-css';
import rename from 'gulp-rename';
export default function processCSS() {
let processors = [
autoprefixer(project.cssProcessor.browsers)
];
return gulp.src(project.cssProcessor.source)
.pipe(lintCSS())
.pipe(sourcemaps.init())
.pipe(sass({
includePaths: project.cssProcessor.sassIncludePaths
}).on('error', sass.logError))
.pipe(postcss(processors))
.pipe(cssnano())
.pipe(sourcemaps.write('.'))
.pipe(rename(path => {
// this means the generated css files are placed directly in assets/css folder instead of a scss sub-folder
path.dirname = path.dirname.replace('scss', '');
}))
.pipe(gulp.dest(project.cssProcessor.output));
}