AdminLTE/Gruntfile.js

173 lines
5.7 KiB
JavaScript
Raw Normal View History

2015-09-19 18:29:39 +00:00
// AdminLTE Gruntfile
2015-02-01 21:25:09 +00:00
module.exports = function (grunt) {
'use strict';
2015-04-15 23:07:57 +00:00
2015-02-01 21:25:09 +00:00
grunt.initConfig({
watch: {
2015-04-15 23:07:57 +00:00
// If any .less file changes in directory "build/less/" run the "less"-task.
2015-02-02 18:38:02 +00:00
files: ["build/less/*.less", "build/less/skins/*.less", "dist/js/app.js"],
2015-02-02 16:52:30 +00:00
tasks: ["less", "uglify"]
2015-02-01 21:25:09 +00:00
},
// "less"-task configuration
2015-04-15 23:07:57 +00:00
// This task will compile all less files upon saving to create both AdminLTE.css and AdminLTE.min.css
2015-02-01 21:25:09 +00:00
less: {
2015-04-15 23:07:57 +00:00
// Development not compressed
2015-02-01 21:25:09 +00:00
development: {
options: {
2015-04-15 23:07:57 +00:00
// Whether to compress or not
2015-02-01 21:25:09 +00:00
compress: false
},
files: {
2015-07-12 13:46:20 +00:00
// compilation.css : source.less
"dist/css/AdminLTE.css": "build/less/AdminLTE.less",
2015-04-03 15:56:51 +00:00
//Non minified skin files
"dist/css/skins/skin-blue.css": "build/less/skins/skin-blue.less",
"dist/css/skins/skin-black.css": "build/less/skins/skin-black.less",
"dist/css/skins/skin-yellow.css": "build/less/skins/skin-yellow.less",
"dist/css/skins/skin-green.css": "build/less/skins/skin-green.less",
"dist/css/skins/skin-red.css": "build/less/skins/skin-red.less",
"dist/css/skins/skin-purple.css": "build/less/skins/skin-purple.less",
2015-04-03 15:56:51 +00:00
"dist/css/skins/skin-blue-light.css": "build/less/skins/skin-blue-light.less",
"dist/css/skins/skin-black-light.css": "build/less/skins/skin-black-light.less",
"dist/css/skins/skin-yellow-light.css": "build/less/skins/skin-yellow-light.less",
"dist/css/skins/skin-green-light.css": "build/less/skins/skin-green-light.less",
"dist/css/skins/skin-red-light.css": "build/less/skins/skin-red-light.less",
"dist/css/skins/skin-purple-light.css": "build/less/skins/skin-purple-light.less",
"dist/css/skins/_all-skins.css": "build/less/skins/_all-skins.less"
2015-02-01 21:25:09 +00:00
}
},
2015-04-15 23:07:57 +00:00
// Production compresses version
2015-02-01 21:25:09 +00:00
production: {
options: {
2015-07-12 13:46:20 +00:00
// Whether to compress or not
2015-02-01 21:25:09 +00:00
compress: true
},
files: {
// compilation.css : source.less
2015-04-15 23:07:57 +00:00
"dist/css/AdminLTE.min.css": "build/less/AdminLTE.less",
// Skins minified
"dist/css/skins/skin-blue.min.css": "build/less/skins/skin-blue.less",
"dist/css/skins/skin-black.min.css": "build/less/skins/skin-black.less",
"dist/css/skins/skin-yellow.min.css": "build/less/skins/skin-yellow.less",
"dist/css/skins/skin-green.min.css": "build/less/skins/skin-green.less",
"dist/css/skins/skin-red.min.css": "build/less/skins/skin-red.less",
"dist/css/skins/skin-purple.min.css": "build/less/skins/skin-purple.less",
2015-04-03 15:56:51 +00:00
"dist/css/skins/skin-blue-light.min.css": "build/less/skins/skin-blue-light.less",
"dist/css/skins/skin-black-light.min.css": "build/less/skins/skin-black-light.less",
"dist/css/skins/skin-yellow-light.min.css": "build/less/skins/skin-yellow-light.less",
"dist/css/skins/skin-green-light.min.css": "build/less/skins/skin-green-light.less",
"dist/css/skins/skin-red-light.min.css": "build/less/skins/skin-red-light.less",
"dist/css/skins/skin-purple-light.min.css": "build/less/skins/skin-purple-light.less",
"dist/css/skins/_all-skins.min.css": "build/less/skins/_all-skins.less"
2015-02-01 21:25:09 +00:00
}
}
2015-02-02 16:52:30 +00:00
},
2015-04-15 23:07:57 +00:00
// Uglify task info. Compress the js files.
2015-02-02 16:52:30 +00:00
uglify: {
options: {
2015-02-02 18:38:02 +00:00
mangle: true,
preserveComments: 'some'
2015-02-02 16:52:30 +00:00
},
my_target: {
files: {
'dist/js/app.min.js': ['dist/js/app.js']
}
}
},
2015-04-15 23:07:57 +00:00
// Build the documentation files
includes: {
build: {
2015-07-12 13:46:20 +00:00
src: ['*.html'], // Source files
dest: 'documentation/', // Destination directory
flatten: true,
cwd: 'documentation/build',
options: {
silent: true,
includePath: 'documentation/build/include'
2015-04-15 23:07:57 +00:00
}
}
},
// Optimize images
image: {
dynamic: {
files: [{
expand: true,
cwd: 'build/img/',
2015-08-16 19:51:13 +00:00
src: ['**/*.{png,jpg,gif,svg,jpeg}'],
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'
}
},
2015-08-22 17:22:37 +00:00
// Validate CSS files
2015-07-25 19:51:57 +00:00
csslint: {
options: {
csslintrc: 'build/less/.csslintrc'
},
dist: [
'dist/css/AdminLTE.css',
]
},
2015-08-22 17:22:37 +00:00
// Validate Bootstrap HTML
bootlint: {
options: {
relaxerror: ['W005']
},
files: ['pages/**/*.html', '*.html']
2015-08-22 17:22:37 +00:00
},
// Delete images in build directory
// After compressing the images in the build/img dir, there is no need
// for them
clean: {
build: ["build/img/*"]
2015-02-01 21:25:09 +00:00
}
});
2015-04-15 23:07:57 +00:00
// Load all grunt tasks
// LESS Compiler
grunt.loadNpmTasks('grunt-contrib-less');
// Watch File Changes
grunt.loadNpmTasks('grunt-contrib-watch');
// Compress JS Files
grunt.loadNpmTasks('grunt-contrib-uglify');
// Include Files Within HTML
grunt.loadNpmTasks('grunt-includes');
// Optimize images
grunt.loadNpmTasks('grunt-image');
// Validate JS code
grunt.loadNpmTasks('grunt-contrib-jshint');
// Delete not needed files
grunt.loadNpmTasks('grunt-contrib-clean');
2015-07-25 19:51:57 +00:00
// Lint CSS
grunt.loadNpmTasks('grunt-contrib-csslint');
2015-08-22 17:22:37 +00:00
// Lint Bootstrap
grunt.loadNpmTasks('grunt-bootlint');
// Linting task
grunt.registerTask('lint', ['jshint', 'csslint', 'bootlint']);
2015-04-15 23:07:57 +00:00
// The default task (running "grunt" in console) is "watch"
2015-02-01 21:25:09 +00:00
grunt.registerTask('default', ['watch']);
};