From 13aa44fe14ee2b6a6b1a5347219b418a7c34a047 Mon Sep 17 00:00:00 2001 From: Abdullah Almsaeed Date: Sat, 25 Jul 2015 15:05:02 -0400 Subject: [PATCH] Added jshint, clean and image plugins to lint JS files, remove build images and compress images respectively --- Gruntfile.js | 62 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 747208663..0ac7e7334 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,5 +1,14 @@ -'use strict'; +/*! + * Bootstrap's Gruntfile + * http://getbootstrap.com + * Copyright 2013-2015 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + + module.exports = function (grunt) { + + 'use strict'; grunt.initConfig({ watch: { @@ -86,15 +95,40 @@ module.exports = function (grunt) { } } }, - cssjanus: { - build: { - files: { - 'dist/css/AdminLTE-rtl.css': 'dist/css/AdminLTE.css', - 'dist/css/AdminLTE-rtl.min.css': 'dist/css/AdminLTE.min.css', - 'bootstrap/css/bootstrap-rtl.css': 'bootstrap/css/bootstrap.css', - 'bootstrap/css/bootstrap-rtl.min.css': 'bootstrap/css/bootstrap.min.css' - } + + // Optimize images + image: { + dynamic: { + files: [{ + expand: true, + cwd: 'build/img/', + src: ['**/*.{png,jpg,gif,svg}'], + dest: 'dist/img/' + }] } + }, + + // Validate JS code + jshint: { + options: { + jshintrc: '.jshintrc' + }, + core: { + src: 'dist/js/app.js' + }, + demo: { + src: 'dist/js/demo.js' + }, + pages: { + src: 'dist/js/pages/*.js' + } + }, + + // Delete images in build directory + // After compressing the images in the build/img dir, there is no need + // for them + clean: { + build: ["build/img/*"] } }); @@ -108,9 +142,13 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-uglify'); // Include Files Within HTML grunt.loadNpmTasks('grunt-includes'); - // Convert CSS to RTL - grunt.loadNpmTasks('grunt-cssjanus'); + // Optimize images + grunt.loadNpmTasks('grunt-image'); + // Validate JS code + grunt.loadNpmTasks('grunt-contrib-jshint'); + // Delete not needed files + grunt.loadNpmTasks('grunt-contrib-clean'); // The default task (running "grunt" in console) is "watch" grunt.registerTask('default', ['watch']); -}; +}; \ No newline at end of file