Skip to content

Instantly share code, notes, and snippets.

@jpgiago
Last active September 22, 2017 01:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpgiago/de17a5ab5d8b51ad34a1 to your computer and use it in GitHub Desktop.
Save jpgiago/de17a5ab5d8b51ad34a1 to your computer and use it in GitHub Desktop.
Gulp.js for Stylus (lost, axis, rupture w/ postcss)
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
gutil = require('gulp-util'),
autoprefixer = require('autoprefixer'),
sourcemaps = require('gulp-sourcemaps'),
postcss = require('gulp-postcss'),
poststylus = require('poststylus'),
stylus = require('gulp-stylus'),
axis = require('axis'),
rupture = require('rupture'),
lost = require('lost'),
jade = require('gulp-jade'),
livereload = require('gulp-livereload');
gulp.task('html', function() {
var YOUR_LOCALS = {};
gulp.src('views/*.jade')
.pipe(jade({
locals: YOUR_LOCALS,
pretty: true
}))
.pipe(gulp.dest('build/'))
.pipe(livereload());
});
gulp.task('styles', function() {
gulp.src('assets/css/main.styl')
.pipe(plumber({errorHandler: function (err) { gutil.beep(); console.log(err);}})) // Beeps if there is an error
.pipe(sourcemaps.init()) // Start Sourcemaps
.pipe(stylus({ // Pipe gulp-stylus through...
use: [
poststylus([ // ... and use PostStylus to render autoprefixer + Lost Grid
'autoprefixer',
'lost'
]),
axis(), // ... and some awesome Stylus goodies
rupture()
]
}))
.pipe(sourcemaps.write('./')) // Render Sourcemaps
.pipe(gulp.dest('build/css/'))
.pipe(livereload());
});
// js
gulp.task('js', function() {
return gulp.src('assets/js/**/*')
.pipe(gulp.dest('build/js'))
.pipe(livereload());
});
// img
gulp.task('img', function() {
return gulp.src('assets/img/**/*')
.pipe(gulp.dest('build/img'))
.pipe(livereload());
});
gulp.task('watch', function() {
livereload.listen({start: true}); // Starts LiveReload plugin
var livereloadPage = function() {
livereload.reload();
};
gulp.watch([
'views/*.jade'], ['html'], livereloadPage );
gulp.watch([
'assets/img/**/*'], ['img'], livereloadPage );
gulp.watch([
'assets/js'], ['js'], livereloadPage );
gulp.watch([
'assets/css/*.styl'], ['styles'], livereloadPage ); // Watch for .styl files
})
gulp.task('default', ['html','styles','js','img','watch']);
{
"name": "gulp-stylus-env",
"version": "1.0.0",
"description": "Stylus dev env using Gulp.",
"dependencies": {
"axis": "^0.5.2",
"autoprefixer": "^6.2.3",
"gulp": "^3.9.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-stylus": "^2.2.0",
"gulp-postcss": "^6.0.1",
"gulp-jade": "^1.1.0",
"lost": "^6.6.3",
"poststylus": "^0.2.2",
"gulp-plumber": "^1.1.0",
"gulp-util": "^3.0.7",
"gulp-livereload": "^3.8.1",
"rupture": "^0.6.1"
},
"devDependencies": {},
"author": "John Paul Giago"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment