Skip to content

Instantly share code, notes, and snippets.

@ddprrt
Created August 11, 2014 07:40
Show Gist options
  • Save ddprrt/da9b631c5b988fe661b8 to your computer and use it in GitHub Desktop.
Save ddprrt/da9b631c5b988fe661b8 to your computer and use it in GitHub Desktop.
WIP: Gruntfile with Sass and Server to use with Patternlab
'use strict';
module.exports = function (grunt) {
// show elapsed time at the end
require('time-grunt')(grunt);
// load all grunt tasks
require('jit-grunt')(grunt);
grunt.initConfig({
watch: {
// Runs Sass and calls Autoprefixer afterwards
sass: {
files: ['source/scss/**/*.scss'],
tasks: ['sass:dev','autoprefixer']
},
// taken from http://bradfrostweb.com/blog/post/using-grunt-with-pattern-lab/
html: {
files: ['source/_patterns/**/*.mustache', 'source/**/*.json'],
tasks: ['shell:patternlabDev'],
options: {
spawn: false
}
}
},
// call PHP from the shell
shell: {
patternlab: {
command: "php core/builder.php -g"
},
patternlabDev: {
command: "php core/builder.php -gp"
}
},
// connect points to 'public', where all your Patternlab files are generated
connect: {
dev: {
options: {
port: 9000,
hostname: '0.0.0.0',
base: 'public/',
open: true
}
}
},
sass: {
dev: {
files: {
'public/css/style.css' : ['source/scss/style.scss']
}
},
test: {
files: {
'public/css/style.css' : ['source/scss/style.scss']
}
},
build: {
options: {
style: 'compressed'
},
files: {
'public/css/style.css' : ['source/scss/style.scss']
}
}
},
autoprefixer: {
options: {
browsers: ['last 2 versions']
},
dist: {
files: [{
expand: true,
cwd: 'public/css/',
src: '{,*/}*.css',
dest: 'public/css/'
}]
}
},
// in some cases, the styleguide does not get deployed, copy it manually
copy: {
styleguide: {
files: [
{expand: true, cwd: 'core/styleguide', src: ['**/*.*'], dest: 'public/styleguide/'},
]
}
}
});
// run the dev task
grunt.registerTask('dev',[
'shell:patternlabDev',
'copy:styleguide',
'sass:dev',
'autoprefixer',
'connect',
'watch'
]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment