Skip to content

Instantly share code, notes, and snippets.

@simbo
Created April 14, 2016 08:53
Show Gist options
  • Save simbo/111a2783fd58cd005e6631af113e55ab to your computer and use it in GitHub Desktop.
Save simbo/111a2783fd58cd005e6631af113e55ab to your computer and use it in GitHub Desktop.
'use strict';
var path = require('path');
var autoprefixer = require('autoprefixer'),
csswring = require('csswring'),
glob = require('glob'),
lost = require('lost'),
mqpacker = require('css-mqpacker');
module.exports = [
'parse stylus to css, pipe through postcss',
function() {
var src = this.paths.css.src,
dest = this.paths.css.dest;
return this.gulp
.src(path.join(src, '*.styl'))
.pipe(this.plugins.plumber())
.pipe(this.plugins.sourcemaps.init())
.pipe(this.plugins.stylint({
config: path.join(this.paths.css.src, '.stylintrc')
}))
.pipe(this.plugins.stylint.reporter())
.pipe(this.plugins.stylint.reporter('fail'))
.pipe(this.plugins.stylus({
paths: [
path.join(src, 'imports'),
path.join(this.paths.cwd, 'node_modules')
],
use: glob.sync(path.join(src, 'functions', '**/*.js'))
.map(function(fn) {
return require(path.relative(__dirname, fn))();
}),
'include css': true,
url: {
name: 'inline-url',
limit: false
}
}))
.pipe(this.plugins.postcss(
[
lost(),
autoprefixer({
browsers: [
'last 2 versions',
'> 0.1%',
'ie 9'
],
remove: false
}),
mqpacker
].concat(this.env !== 'development' ?
[
csswring({
preserveHacks: true
})
] : []
)
))
.pipe(this.plugins.sourcemaps.write('.', {
includeContent: true,
sourceRoot: '.'
}))
.pipe(this.gulp.dest(dest))
.pipe(this.reload({stream: true}));
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment