Skip to content

Instantly share code, notes, and snippets.

@kanakiyajay
Created May 3, 2015 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanakiyajay/e7117037ae1d1f820947 to your computer and use it in GitHub Desktop.
Save kanakiyajay/e7117037ae1d1f820947 to your computer and use it in GitHub Desktop.
Gruntfile.js and package.json utilizing load-grunt-tasks, copy, concat, cssmin, htmlmin, uglify, filerev
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
copy: {
generated: {
src: 'index.html',
dest: 'dist/index.html'
}
},
filerev: {
options: {
encoding: 'utf8',
algorithm: 'md5',
length: 20
},
source: {
files: [{
src: [
'dist/js/*.js',
'dist/css/*.css'
]
}]
}
},
useminPrepare: {
html: 'index.html',
options: {
dest: 'dist'
}
},
usemin: {
html: 'dist/index.html',
options: {
assetsDirs: ['dist', 'dist/css', 'dist/js', 'css', 'js']
}
},
htmlmin: {
dist: {
options: {
removeComments: true,
collapseWhitespace: true
},
files: {
'dist/index.html': 'dist/index.html'
}
}
}
});
grunt.registerTask('default', [
'copy:generated',
'useminPrepare',
'concat',
'uglify',
'cssmin',
'filerev',
'usemin',
'htmlmin'
]);
};
{
"name": "20-grunt-contrib-htmlmin",
"version": "0.0.1",
"description": "Grunt plugin to minify html files easily",
"main": "Gruntfile.js",
"repository": {
"type": "git",
"url": "git://github.com/kanakiyajay/grunt-tasks.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Jay Kanakiya",
"license": "ISC",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-cssmin": "^0.12.2",
"grunt-contrib-htmlmin": "^0.4.0",
"grunt-contrib-uglify": "^0.9.1",
"grunt-filerev": "^2.3.1",
"grunt-usemin": "^3.0.0",
"load-grunt-tasks": "^3.1.0"
}
}
@kanakiyajay
Copy link
Author

Created for Grunt Tutorial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment