Skip to content

Instantly share code, notes, and snippets.

@alterebro
Last active August 29, 2015 14:02
Show Gist options
  • Save alterebro/cd64602013ef31530227 to your computer and use it in GitHub Desktop.
Save alterebro/cd64602013ef31530227 to your computer and use it in GitHub Desktop.
/* -----------------------
root
├─ index.html
├─ dev
│ ├─ hmtl
│ ├─ images
│ ├─ js
│ └─ less
└─ frontend
├─ css
├─ images
└─ javascript
----------------------- */
module.exports = function(grunt) {
grunt.initConfig({
imagemin: {
dynamic: {
options: {
optimizationLevel: 7
},
files: [{
expand: true,
cwd: 'dev/images/',
src: ['*.{png,jpg,gif}'],
dest: 'frontend/images/'
}]
}
},
less: {
development: {
options: {
compress: true,
yuicompress: true,
optimization: 2
},
files: {
"frontend/css/app.min.css": [
"dev/less/normalize.less",
"dev/less/app.less"
]
}
}
},
htmlmin: {
dist: {
options: {
removeComments: true,
collapseWhitespace: true
},
files: {
// 'destination': 'source'
'index.html': 'dev/html/index.html'
}
}
},
pkg: grunt.file.readJSON('package.json'),
uglify: {
dist: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %>\n' +
'<%= grunt.template.today("yyyy-mm-dd h:MM:ss TT") %> */\n'
},
files: {
'frontend/javascript/app.min.js': [
'dev/js/jquery-2.1.1.min.js',
'dev/js/sammy-latest.min.js',
'dev/js/app.js',
]
}
}
},
watch: {
styles: {
files: ['dev/html/*.html', 'dev/less/*.less', 'dev/js/*.js'],
tasks: ['htmlmin','less','uglify'],
options: {
nospawn: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['watch']);
grunt.registerTask('imagize', ['imagemin']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment