Last active
February 9, 2017 11:14
-
-
Save behrooz-tahanzadeh/70a8ec78c3cb65e9013c to your computer and use it in GitHub Desktop.
Grunt description file to minify every Javascript file and put it beside its sources file
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) { | |
// Project configuration. | |
grunt.initConfig( | |
{ | |
pkg: grunt.file.readJSON('package.json'), | |
uglify: | |
{ | |
options: | |
{ | |
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' | |
}, | |
build: | |
{ | |
expand:true, | |
src: ['<%= pkg.target %>**/*.js', '!<%= pkg.target %>**/*.min.js'], | |
dest: './', | |
ext:'.min.js' | |
} | |
}, | |
watch: | |
{ | |
scripts: | |
{ | |
files: ['<%= pkg.target %>**/*.js', '!<%= pkg.target %>**/*.min.js'], | |
tasks: ['uglify'], | |
options: | |
{ | |
spawn: false, | |
}, | |
} | |
} | |
}); | |
// Load the plugin that provides the "uglify" task. | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
// Default task(s); | |
grunt.registerTask('default', ['uglify', 'watch']); | |
}; |
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
{ | |
"name": "Project Name", | |
"version": "1.0.0", | |
"target": "src\/", | |
"devDependencies": | |
{ | |
"grunt": "~0.4.5", | |
"grunt-contrib-uglify": "~0.5.0", | |
"grunt-contrib-watch": "^0.6.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@behrooz-tahanzadeh nobody uses grunt anymore! try gulp! :)) npm install --save-dev gulp-minify