1.

Which Are The Most Used Grunt Plugins?

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.

  1. module.exports = function(grunt) {
  2. grunt.initConfig({
  3. pkg: grunt.file.readJSON('package.json'),
  4. concat: {
  5. options: {
  6. separator: ';'
  7. },
  8. dist: {
  9. src: ['src/**/*.js'],
  10. dest: 'dist/<%= pkg.name %>.js'
  11. }
  12. },
  13. uglify: {
  14. options: {
  15. BANNER: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */n'
  16. },
  17. dist: {
  18. files: {
  19. 'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
  20. }
  21. }
  22. },
  23. jshint: {
  24. files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
  25. options: {
  26. // options here to override JSHint defaults
  27. globals: {
  28. jQuery: true,
  29. console: true,
  30. module: true,
  31. document: true
  32. }
  33. }
  34. }
  35. });
  36. grunt.loadNpmTasks('grunt-contrib-uglify');
  37. grunt.loadNpmTasks('grunt-contrib-jshint');
  38. grunt.loadNpmTasks('grunt-contrib-concat');
  39. grunt.registerTask('test', ['jshint']);
  40. grunt.registerTask('default', ['jshint', 'concat', 'uglify']);
  41. };

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.



Discussion

No Comment Found