Created
May 13, 2014 08:07
-
-
Save lgladdy/05774c794bedbbde366c to your computer and use it in GitHub Desktop.
This is the gruntfile that powers gladdy.co.uk. It's for the blog post here: http://www.gladdy.co.uk/blog/2014/04/13/using-uncss-and-grunt-uncss-with-wordpress/
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
module.exports = function(grunt) { | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
uglify: { | |
options: { | |
sourceMap: true, | |
sourceMapIncludeSources: true, | |
sourceMapIn: 'js/app.coffee.js.map' | |
}, | |
compile: { | |
files: { | |
'js/app.js': [ | |
'public/components/modernizr/modernizr.js', | |
'public/components/jquery/dist/jquery.js', | |
'public/components/foundation/js/foundation.js', | |
'public/components/jquery.smooth-scroll/jquery.smooth-scroll.js', | |
'public/components/WOW/dist/wow.js', | |
'js/custom_retina.js', | |
'js/app.coffee.js' | |
] | |
} | |
}, | |
minify: { | |
files: { | |
'js/app.min.js': 'js/app.js' | |
} | |
} | |
}, | |
coffee: { | |
compile: { | |
options: { | |
sourceMap: true | |
}, | |
files: { | |
'js/app.coffee.js': ['coffee/**/*.coffee'] | |
} | |
} | |
}, | |
sass: { | |
options: { | |
loadPath: ['public/components/foundation/scss','public/components/bourbon/dist','public/sideload/animate'], | |
sourcemap: true, | |
quiet: true | |
}, | |
dist: { | |
options: { | |
style: 'compressed' | |
}, | |
files: { | |
'css/app.cmin.css': 'css/app.clean.css' | |
} | |
}, | |
dev: { | |
options: { | |
style: 'expanded' | |
}, | |
files: { | |
'css/app.css': 'scss/app.scss' | |
} | |
} | |
}, | |
watch: { | |
config: { | |
files: [ 'Gruntfile.js' ], | |
options: { reload: true } | |
}, | |
grunt: { files: ['Gruntfile.js'] }, | |
images: { | |
files: 'img/**/*.{png,jpg,jpeg}', | |
tasks: ['imagemin:production'], | |
options: { | |
livereload: true | |
} | |
}, | |
vectors: { | |
files: 'img/**/*.svg', | |
tasks: ['svgmin:production'], | |
options: { | |
livereload: true | |
} | |
}, | |
sass: { | |
files: 'scss/**/*.scss', | |
tasks: ['sass:dev'], | |
options: { | |
livereload: true | |
} | |
}, | |
coffee: { | |
files: 'coffee/**/*.coffee', | |
tasks: ['coffee:compile','uglify:compile','uglify:minify','jshint'], | |
options: { | |
livereload: true | |
} | |
}, | |
js: { | |
files: ['js/*.js'], | |
tasks: ['concat','uglify:coffee','jshint'], | |
options: { | |
livereload: true | |
} | |
}, | |
php: { | |
files: ['**/*.php'], | |
options: { | |
livereload: true | |
} | |
} | |
}, | |
// JsHint your javascript | |
jshint: { | |
all: ['js/app.coffee.js', '!js/modernizr.js', '!js/*.min.js', '!js/vendor/**/*.js', '!js/html**.js'], | |
options: { | |
browser: true, | |
curly: false, | |
eqeqeq: false, | |
eqnull: true, | |
expr: true, | |
immed: true, | |
newcap: true, | |
noarg: true, | |
smarttabs: true, | |
sub: true, | |
undef: false | |
} | |
}, | |
// Image min | |
imagemin: { | |
production: { | |
files: [ | |
{ | |
expand: true, | |
cwd: 'img', | |
src: '**/*.{png,jpg,jpeg}', | |
dest: 'img' | |
} | |
] | |
} | |
}, | |
// SVG min | |
svgmin: { | |
production: { | |
files: [ | |
{ | |
expand: true, | |
cwd: 'img', | |
src: '**/*.svg', | |
dest: 'img' | |
} | |
] | |
} | |
}, | |
exec: { | |
get_grunt_sitemap: { | |
command: 'curl --silent --output sitemap.json http://gladdy.local/?show_sitemap' | |
} | |
}, | |
uncss: { | |
dist: { | |
options: { | |
ignore : [/expanded/,/js/,/wp-/,/align/,/admin-bar/,'.swing'], | |
stylesheets : ['css/app.css'], | |
ignoreSheets : [/fonts.googleapis/], | |
urls : [], //Overwritten in load_sitemap_and_uncss task | |
}, | |
files: { | |
'css/app.clean.css': ['**/*.php'] | |
} | |
} | |
} | |
}); | |
grunt.loadNpmTasks('grunt-contrib-sass'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-imagemin'); | |
grunt.loadNpmTasks('grunt-contrib-coffee'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-svgmin'); | |
grunt.loadNpmTasks('grunt-notify'); | |
grunt.loadNpmTasks('grunt-exec'); | |
grunt.loadNpmTasks('grunt-uncss'); | |
grunt.registerTask('build', ['coffee:compile', 'uglify:compile', 'uglify:minify', 'jshint', 'imagemin:production', 'svgmin:production']); | |
grunt.registerTask('default', ['sass:dev', 'build', 'watch']); | |
grunt.registerTask('deploy', ['exec:get_grunt_sitemap','load_sitemap_json','uncss:dist','sass:dist']); | |
grunt.registerTask('load_sitemap_json', function() { | |
var sitemap_urls = grunt.file.readJSON('./sitemap.json'); | |
grunt.config.set('uncss.dist.options.urls', sitemap_urls); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mine is "Fatal error: promise is not defined" on uncss:dist ? I've search the issue page on giakki and addyosmani, but i cant seem to find anyone having my error.