|
Answer» Though there are tons of PLUGINS which you can use, but below are the most used.
- watch: RUN predefined tasks whenever watched file PATTERNS are added, changed or deleted.
- jshint: Validate files with JSHint
- uglify: Minify files with UglifyJS
- concat: Concatenate files.
- cssmin: Minify CSS
- less: Compile LESS files to CSS.
Below is a sample gruntfile.JS for your reference.
- module.exports = function(grunt) {
- grunt.initConfig({
- pkg: grunt.file.readJSON('package.json'),
- concat: {
- options: {
- separator: ';'
- },
- dist: {
- src: ['src/**/*.js'],
- dest: 'dist/<%= pkg.name %>.js'
- }
- },
- uglify: {
- options: {
- BANNER: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */n'
- },
- dist: {
- files: {
- 'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
- }
- }
- },
- jshint: {
- files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
- options: {
- // options here to override JSHint defaults
- globals: {
- jQuery: true,
- console: true,
- module: true,
- document: true
- }
- }
- }
- });
- grunt.loadNpmTasks('grunt-contrib-uglify');
- grunt.loadNpmTasks('grunt-contrib-jshint');
- grunt.loadNpmTasks('grunt-contrib-concat');
- grunt.registerTask('test', ['jshint']);
- grunt.registerTask('default', ['jshint', 'concat', 'uglify']);
- };
Though there are tons of plugins which you can use, but below are the most used. Below is a sample gruntfile.js for your reference.
|