Last active
December 22, 2015 13:19
-
-
Save mattbanks/6478306 to your computer and use it in GitHub Desktop.
Grunt Setup with LESS
This file contains 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) { | |
// load all grunt tasks matching the `grunt-*` pattern | |
require('load-grunt-tasks')(grunt); | |
grunt.initConfig({ | |
// watch for changes and trigger compass, jshint, uglify and livereload | |
watch: { | |
less: { | |
files: ['assets/less/**/*.less'], | |
tasks: ['less:development'] | |
}, | |
js: { | |
files: '<%= jshint.all %>', | |
tasks: ['jshint', 'uglify'] | |
}, | |
livereload: { | |
options: { livereload: true }, | |
files: ['style.css', 'assets/js/*.js', '*.html', '*.php', 'assets/images/**/*.{png,jpg,jpeg,gif,webp,svg}'] | |
} | |
}, | |
// less | |
less: { | |
development: { | |
options: { | |
paths: ["assets/css"] | |
}, | |
files: { | |
"path/to/result.css": "path/to/source.less" | |
} | |
}, | |
production: { | |
options: { | |
paths: ["assets/css"], | |
yuicompress: true | |
}, | |
files: { | |
"path/to/result.css": "path/to/source.less" | |
} | |
} | |
} | |
// javascript linting with jshint | |
jshint: { | |
options: { | |
jshintrc: '.jshintrc', | |
"force": true | |
}, | |
all: [ | |
'Gruntfile.js', | |
'assets/js/source/**/*.js' | |
] | |
}, | |
// uglify to concat, minify, and make source maps | |
uglify: { | |
plugins: { | |
options: { | |
sourceMap: 'assets/js/plugins.js.map', | |
sourceMappingURL: 'plugins.js.map', | |
sourceMapPrefix: 2 | |
}, | |
files: { | |
'assets/js/plugins.min.js': [ | |
'assets/js/source/plugins.js', | |
// 'assets/js/vendor/yourplugin/yourplugin.js', | |
] | |
} | |
}, | |
main: { | |
options: { | |
sourceMap: 'assets/js/main.js.map', | |
sourceMappingURL: 'main.js.map', | |
sourceMapPrefix: 2 | |
}, | |
files: { | |
'assets/js/main.min.js': [ | |
'assets/js/source/main.js' | |
] | |
} | |
} | |
}, | |
// image optimization | |
imagemin: { | |
dist: { | |
options: { | |
optimizationLevel: 7, | |
progressive: true | |
}, | |
files: [{ | |
expand: true, | |
cwd: 'assets/images/', | |
src: '**/*', | |
dest: 'assets/images/' | |
}] | |
} | |
}, | |
}); | |
// register task | |
grunt.registerTask('default', ['watch']); | |
grunt.resisterTask('build', 'less:production') | |
}; |
This file contains 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
{ | |
"name": "wordpress-starter-theme", | |
"version": "1.0.0", | |
"dependencies": { | |
"load-grunt-tasks": "~0.1.0" | |
}, | |
"devDependencies": { | |
"grunt": "~0.4.1", | |
"grunt-contrib-less": "~0.7.0", | |
"grunt-contrib-jshint": "~0.6.4", | |
"grunt-contrib-uglify": "~0.2.4", | |
"grunt-contrib-watch": "~0.5.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment