Skip to content

Instantly share code, notes, and snippets.

@theY4Kman
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save theY4Kman/abe998216b12e09bd47b to your computer and use it in GitHub Desktop.

Select an option

Save theY4Kman/abe998216b12e09bd47b to your computer and use it in GitHub Desktop.
A little helper which makes incremental path generation a cinch
// Helper to simplify incremental generation and storage of paths
var Path = function Path(_path) {
this.value = _path;
};
Path.prototype = {
'toString': function() {
return this.value;
},
'join': function() {
var args = Array.prototype.slice.call(arguments, 0);
args.unshift(this.value);
return new Path(path.join.apply(null, args));
}
};
// Example usage:
var paths = new Path(__dirname);
paths.static = paths.join('moodlog/static');
paths.css = paths.static.join('css');
paths.js = paths.static.join('js');
paths.font = paths.static.join('font');
paths.img = paths.static.join('img');
paths.sass = paths.static.join('sass');
paths.sass.pattern = paths.sass.join('*.scss');
gulp.task('styles', function() {
gulp.src(paths.sass.pattern.value)
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}))
.pipe(minifycss())
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('/', {includeContent: false}))
.pipe(gulp.dest(paths.css.value));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment