AdminLTE/Gruntfile.js

160 lines
3.5 KiB
JavaScript
Raw Normal View History

2015-09-19 18:29:39 +00:00
// AdminLTE Gruntfile
2015-11-04 18:51:10 +00:00
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-11-04 18:51:10 +00:00
// files: ["build/less/*.less", "build/less/skins/*.less", "dist/js/app.js"],
files: ["build/scss/*.scss", "build/scss/skins/*.scss", "dist/js/app.js"],
tasks: ["sass", "uglify"]
2015-02-02 16:52:30 +00:00
},
2015-10-31 21:00:35 +00:00
// SASS compiler
sass: {
development: {
options: {
style: 'expanded'
},
files: {
'dist/tmp/AdminLTE.css': 'build/scss/AdminLTE.scss'
}
},
production: {
options: {
style: 'compressed'
},
files: {
'dist/tmp/AdminLTE.min.css': 'build/scss/AdminLTE.scss'
}
}
},
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-10-31 21:00:35 +00:00
2015-11-04 18:51:10 +00:00
// Compile ECMA6 to ECMA5
babel: {
options: {
sourceMap: true,
presets: ['es2015']
},
dist: {
files: {
'dist/js/AdminLTE.js': 'build/js/AdminLTE.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');
2015-10-31 21:00:35 +00:00
// SASS compiler
grunt.loadNpmTasks('grunt-sass');
2015-04-15 23:07:57 +00:00
// 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');
2015-11-04 18:51:10 +00:00
// Grunt Babel to compile ECMA6 to ECMA5
grunt.loadNpmTasks('grunt-babel');
2015-08-22 17:22:37 +00:00
// 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']);
};