Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A Gulp task pseudo-code for exporting from Pattern Lab into an adjacent style guide directory
/******************************************************
* PATTERN LAB NODE
* EDITION-NODE-GULP
* The gulp wrapper around patternlab-node core, providing tasks to interact with the core library and move supporting frontend assets.
******************************************************/
var gulp = require('gulp'),
path = require('path'),
browserSync = require('browser-sync').create(),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
chalk = require('chalk'),
copy = require('gulp-copy'),
gulpRemoveHtml = require('gulp-remove-html');
/******************************************************
* COPY TASKS - stream assets from source to destination
******************************************************/
// This is the task that exports the results from Pattern Lab
// into the Jekyll style guide that lives outside of this repository
gulp.task('copy:export-to-styleguide', function (done) {
// Export public/patterns directory to style guide's includes
// This is used to include the actual code into the code samples
gulp.src(['public/patterns/**/*', '!public/patterns/**/*.rendered.html'])
.pipe(gulp.dest('../[style-guide-directory]/_includes/patterns'));
// Export public/patterns directory to style guide patterns directory
// This is used to pipe the live patterns into the iframe
gulp.src(['public/patterns/**/*', '!public/patterns/**/*.rendered.html'])
.pipe(gulp.dest('../[style-guide-directory]/patterns'));
// Export css directory to style guide css directory
gulp.src('public/css/**/*')
.pipe(gulp.dest('../[style-guide-directory]/css'));
// Export js directory to style guide js directory
gulp.src('public/js/**/*')
.pipe(gulp.dest('../[style-guide-directory]/js'));
// Export icons to style guide root directory
gulp.src('public/icons.svg')
.pipe(gulp.dest('../[style-guide-directory]'));
// Export images directory to style guide images directory
gulp.src('public/images/**/*')
.pipe(gulp.dest('../[style-guide-directory]/images'));
// Export images directory to style guide images directory
gulp.src('public/images/**/*')
.pipe(gulp.dest('../[style-guide-directory]/images'));
done();
});
gulp.task('patternlab:build', gulp.series([PL-specific tasks], build));
/******************************************************
* COMPOUND TASKS
******************************************************/
gulp.task('style-guide-export', gulp.series('patternlab:build', 'copy:export-to-styleguide', 'strip'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment