Skip to content

Instantly share code, notes, and snippets.

@shramee
Last active March 21, 2016 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shramee/27b27c35c38cb5df2165 to your computer and use it in GitHub Desktop.
Save shramee/27b27c35c38cb5df2165 to your computer and use it in GitHub Desktop.
Gruntfile for using SASS with Grunt and Autoprefixer for a WordPress theme with SASS init `sass/style.scss` directory
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/* Autoprefixing all css files in theme root */
autoprefixer: {
options : {
browsers : ['last 2 versions'],
},
multiple_files : {
expand : true,
flatten : true,
src : '*.css',
dest : ''
}
},
/* Decompiling sass */
sass: {
/* Decompiling `sass/style.scss` to HUMAN READABLE (expanded) style.dev.css */
dev: {
options: {
style : 'expanded',
sourcemap: 'none'
},
files: {
'style.dev.css' : 'sass/style.scss'
}
},
/* Decompiling `sass/style.scss` to MINIFIED (compressed) style.css */
dist: {
options: {
style : 'compressed',
sourcemap: 'none'
},
sourcemap: 'none',
files: {
'style.css' : 'sass/style.scss'
}
}
},
/* Watch scss files */
watch : {
css: {
files: '**/*.scss',
tasks: [ 'sass', 'autoprefixer' ]
}
}
});
/* Load tasks */
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
/* Register default task */
grunt.registerTask('default',['watch']);
};
{
"name": "My theme",
"version": "0.7.0",
"description": "My awesome theme for dudes and dudettes",
"author": "Shramee",
"license": "GPL-2.0+",
"main": "index.php",
"keywords": [
"sass",
"grunt",
"autoprefixer",
"wordpress"
],
"repository": {
"type": "git",
"url": "https://github.com/myusername/mytheme.git"
},
"bugs": {
"url": "https://github.com/myusername/mytheme/issues"
},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-sass": "~1.0.0",
"grunt-contrib-watch": "~1.0.0",
"grunt-autoprefixer": "~3.0.4"
},
"dependencies": {
"grunt": "~0.4.5",
"grunt-autoprefixer": "~3.0.4",
"grunt-contrib-sass": "~1.0.0",
"grunt-contrib-watch": "~1.0.0"
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment