Last active
August 29, 2015 14:19
-
-
Save theY4Kman/abe998216b12e09bd47b to your computer and use it in GitHub Desktop.
A little helper which makes incremental path generation a cinch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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