-
Notifications
You must be signed in to change notification settings - Fork 5
Gulp: living styleguides with node sassdown
Marco Solazzi edited this page Nov 5, 2015
·
3 revisions
This recipe will guide you through the installation and configuration of node-sassdown for live styleguide driven development.
Install dependencies:
npm install node-sassdown --save-devCreate a new file build/gulp-tasks/styleguide.js:
module.exports = function (gulp, $, options) {
gulp.task('styleguide', function (done) {
var Sassdown = require('node-sassdown');
var srcGlob = '{*/*.scss}';
var srcPath = options.assetsPath('src.sass');
var destPath = options.paths.dist.root + '/styleguide/';
var opts = {
assets: [options.assetsPath('dist.css', '{styleguide,application}.css')],
excludeMissing: true,
readme: 'README.md',
title: 'Living Styleguide',
baseUrl: '/styleguide/'
};
var sassdown = new Sassdown(srcGlob, srcPath, destPath, opts);
sassdown.run(done);
});
};Then create application/assets/stylesheets/styleguide.scss. This file will be included in every auto-generated iframe with code examples.
For further customization see node-sassdown documentation
Open build/gulp-config/properties.js and set property styleguideDriven to true.
Edit gulpfile.js adding adding before tasks.push(done); (line 104) the following lines:
if (options.styleguideDriven) {
tasks.push('styleguide');
}Finally , to enable styleguide rebuild on stylesheets' changes, edit build/gulp-tasks/serve.js and replace this lines:
gulp.watch([
assetsPath('src.sass', '/**/*.{scss,sass}'),
'!' + assetsPath('src.sass', '**/*scsslint_tmp*.{sass,scss}') //exclude scss lint files
], ['styles']);with:
gulp.watch([
assetsPath('src.sass', '/**/*.{scss,sass}'),
'!' + assetsPath('src.sass', '**/*scsslint_tmp*.{sass,scss}') //exclude scss lint files
], (options.styleguideDriven ? ['styles', 'styleguide'] : ['styles']));