Created
December 31, 2013 12:16
-
-
Save Ajeey/8195894 to your computer and use it in GitHub Desktop.
Grunt gist
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
/* | |
TO DO | |
1) Reduce CSS duplication | |
- Ideally just a single build - global.scss turns into /build/global.css | |
- Can Autoprefixer output minified? | |
- If it can, is it as good as cssmin? | |
- Could Sass be used again to minify instead? | |
- If it can, is it as good as cssmin? | |
2) Better JS dependency management | |
- Require js? | |
- Can it be like the Asset Pipeline where you just do //= require "whatever.js" | |
3) Is HTML minification worth it? | |
4) Set up a Jasmine test just to try it. | |
5) Can this Gruntfile.js be abstracted into smaller parts? | |
- https://github.com/cowboy/wesbos/commit/5a2980a7818957cbaeedcd7552af9ce54e05e3fb | |
*/ | |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
sass: { | |
dist: { | |
options: { | |
// cssmin will minify later | |
style: 'expanded' | |
}, | |
files: { | |
'css/build/global.css': 'css/global.scss' | |
} | |
} | |
}, | |
autoprefixer: { | |
options: { | |
browsers: ['last 2 version'] | |
}, | |
multiple_files: { | |
expand: true, | |
flatten: true, | |
src: 'css/build/*.css', | |
dest: 'css/build/prefixed/' | |
} | |
}, | |
cssmin: { | |
combine: { | |
files: { | |
'css/build/minified/global.css': ['css/build/prefixed/global.css'] | |
} | |
} | |
}, | |
jshint: { | |
beforeconcat: ['js/*.js'] | |
}, | |
concat: { | |
dist: { | |
src: [ | |
'js/libs/*.js', | |
'js/global.js' | |
], | |
dest: 'js/build/production.js' | |
} | |
}, | |
uglify: { | |
build: { | |
src: 'js/build/production.js', | |
dest: 'js/build/production.min.js' | |
} | |
}, | |
imagemin: { | |
dynamic: { | |
files: [{ | |
expand: true, | |
cwd: 'images/', | |
src: ['**/*.{png,jpg,gif}'], | |
dest: 'images/' | |
}] | |
} | |
}, | |
watch: { | |
options: { | |
livereload: true, | |
}, | |
scripts: { | |
files: ['js/*.js'], | |
tasks: ['concat', 'uglify', 'jshint'], | |
options: { | |
spawn: false, | |
} | |
}, | |
css: { | |
files: ['css/*.scss'], | |
tasks: ['sass', 'autoprefixer', 'cssmin'], | |
options: { | |
spawn: false, | |
} | |
}, | |
images: { | |
files: ['images/**/*.{png,jpg,gif}', 'images/*.{png,jpg,gif}'], | |
tasks: ['imagemin'], | |
options: { | |
spawn: false, | |
} | |
} | |
}, | |
connect: { | |
server: { | |
options: { | |
port: 8000, | |
base: './' | |
} | |
} | |
}, | |
}); | |
require('load-grunt-tasks')(grunt); | |
// Default Task is basically a rebuild | |
grunt.registerTask('default', ['concat', 'uglify', 'sass', 'imagemin']); | |
grunt.registerTask('dev', ['connect', 'watch']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment