Created
August 11, 2014 07:40
-
-
Save ddprrt/da9b631c5b988fe661b8 to your computer and use it in GitHub Desktop.
WIP: Gruntfile with Sass and Server to use with Patternlab
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
'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