Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Gruntfile that I use for projects

View Gruntfile.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
// http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically
module.exports = function(grunt) {
 
/**
* Saves having to declare each dependency
*/
require( "matchdep" ).filterDev( "grunt-*" ).forEach( grunt.loadNpmTasks );
 
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
 
uglify: {
options: {
compress: true,
mangle: true,
report: 'min',
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
files: {
"js/all.min.js": ["js/libs/zepto-1.0.1.js", "js/plugins/*.js", "js/main.js"]
}
}
},
 
sass: {
build: {
files: {
'css/global.min.css': 'css/global.scss'
},
options: {
style: 'expanded'
}
}
},
 
watch: {
scripts: {
files: ['js/**/*.js', 'js/main.js'],
tasks: ['uglify'],
options: {
spawn: false
}
},
 
css: {
files: ['css/**/*.scss'],
tasks: ['sass']
},
 
styles: {
files: ['css/global.min.css'],
tasks: ['autoprefixer', 'cssmin'],
options: {
spawn: false
}
}
},
 
cssmin: {
minify: {
expand: true,
cwd: 'css/',
src: ['global.min.css'],
dest: 'css/',
ext: '.min.css'
}
},
 
autoprefixer: {
dist: {
files: {
'css/global.min.css': 'css/global.min.css'
}
}
},
 
imagemin: {
png: {
options: {
optimizationLevel: 7
},
files: [
{
// Set to true to enable the following options…
expand: true,
// cwd is 'current working directory'
cwd: 'images/',
src: ['*.png'],
// Could also match cwd line above. i.e. project-directory/img/
dest: 'images/',
ext: '.png'
}
]
},
jpg: {
options: {
progressive: true
},
files: [
{
// Set to true to enable the following options…
expand: true,
// cwd is 'current working directory'
cwd: 'images/',
src: ['*.jpg'],
// Could also match cwd. i.e. project-directory/img/
dest: 'images/',
ext: '.jpg'
}
]
}
}
 
});
 
};
View Gruntfile.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{
"name": "project-name",
"version": "0.1.0",
"repository": {
"type": "git",
"url": ""
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-uglify": "~0.2.4",
"grunt-contrib-imagemin": "~0.1.4",
"grunt-contrib-sass": "*",
"grunt-contrib-watch": "~0.5.3",
"matchdep": "*",
"grunt-autoprefixer": "*",
"grunt-contrib-cssmin": "*"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.