Skip to content

Instantly share code, notes, and snippets.

@matt-bailey
Created May 8, 2015 12:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt-bailey/65ecc6d498348d5ff5e9 to your computer and use it in GitHub Desktop.
Save matt-bailey/65ecc6d498348d5ff5e9 to your computer and use it in GitHub Desktop.
SC5 Style Guide Generator Grunt usage instructions
module.exports = function(grunt) {
var gulp = require('gulp'),
styleguide = require('sc5-styleguide');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
files: {
'main.css': 'main.scss'
}
}
},
gulp: {
'styleguide-generate': function() {
var outputPath = 'output';
return gulp.src(['main.scss'])
.pipe(styleguide.generate({
title: 'My Styleguide',
server: true,
rootPath: outputPath
}))
.pipe(gulp.dest(outputPath));
},
'styleguide-applystyles': function() {
gulp.src('main.scss')
.pipe(styleguide.applyStyles())
.pipe(gulp.dest('output'));
}
},
watch: {
scss: {
files: '**/*.scss',
tasks: ['sass', 'gulp:styleguide-generate', 'gulp:styleguide-applystyles']
}
}
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-gulp');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['gulp:styleguide-generate', 'gulp:styleguide-applystyles', 'watch']);
};
@matt-bailey
Copy link
Author

I've just started looking into the brilliant SC5 Style Guide Generator, but I found the Grunt usage instructions a little incomplete. So here's their Grunt code example, but expanded a bit so it just works.

What you need to do:

1: Create a basic package.json file
2: Install this stuff:

npm install sc5-styleguide --save-dev
npm install gulp --save-dev
npm install grunt-gulp --save-dev
npm install grunt-sass --save-dev
npm install grunt-contrib-watch --save-dev

3: Create a Gruntfile.js file and paste in the code above.
4: Create a main.scss file and put some CSS in it using the KSS documenting syntax
5: Run grunt
6: Assuming you don't get any errors, in your browser go to http://localhost:3000/
7: Ta da!

Obviously this is just a really simple example with one SCSS file, but it's enough to get things started and see how it works.

@sighonara
Copy link

Thank you. This was very helpful. Wasn't sure what was failing with the standard documentation, but your guide got me in the right direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment