AdminLTE/Gruntfile.js

215 lines
5 KiB
JavaScript
Raw Normal View History

2015-09-19 20:29:39 +02:00
// AdminLTE Gruntfile
2015-11-04 19:51:10 +01:00
2015-02-01 22:25:09 +01:00
module.exports = function (grunt) {
2015-11-11 20:29:54 +01:00
'use strict'
2015-04-16 01:07:57 +02:00
2015-02-01 22:25:09 +01:00
grunt.initConfig({
2015-11-11 20:29:54 +01:00
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*!\n' +
' * AdminLTE v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
' * Copyright 2014-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Project website Almsaeed Studio (https://almsaeedstudio.com)\n' +
' * Licensed under MIT (https://github.com/almasaeed2010/AdminLTE/blob/master/LICENSE)\n' +
' */\n',
// Watch files for changes and invoke appropriate compiler
2015-02-01 22:25:09 +01:00
watch: {
2015-11-11 20:29:54 +01:00
sass: {
files: ['build/scss/*.scss', 'build/scss/skins/*.scss'],
tasks: ['sass']
},
es6: {
files: ['build/js/src/*.js'],
2016-01-16 17:27:23 +01:00
tasks: ['concat', 'babel', 'uglify']
2015-11-11 20:29:54 +01:00
},
js: {
2016-01-16 17:27:23 +01:00
files: ['dist/js/adminlte.js', 'dist/js/app.js'],
2015-11-11 20:29:54 +01:00
tasks: ['uglify']
}
2015-02-02 17:52:30 +01:00
},
2015-10-31 22:00:35 +01:00
// SASS compiler
sass: {
development: {
options: {
style: 'expanded'
},
files: {
2015-11-09 14:51:11 +01:00
'dist/css/AdminLTE.css': 'build/scss/AdminLTE.scss'
2015-10-31 22:00:35 +01:00
}
},
production: {
options: {
style: 'compressed'
},
files: {
2015-11-11 20:29:54 +01:00
'dist/css/adminlte.min.css': 'build/scss/AdminLTE.scss'
2015-10-31 22:00:35 +01:00
}
}
},
2015-11-11 20:29:54 +01:00
// Compress the js files.
2015-02-02 17:52:30 +01:00
uglify: {
options: {
2015-02-02 19:38:02 +01:00
mangle: true,
preserveComments: 'some'
2015-02-02 17:52:30 +01:00
},
2015-11-11 20:29:54 +01:00
target: {
2015-02-02 17:52:30 +01:00
files: {
2015-11-11 20:29:54 +01:00
'dist/js/adminlte.min.js': ['dist/js/adminlte.js'],
2015-02-02 17:52:30 +01:00
'dist/js/app.min.js': ['dist/js/app.js']
}
}
},
2015-10-31 22:00:35 +01:00
2015-11-11 20:29:54 +01:00
// Compile ES6
2015-11-04 19:51:10 +01:00
babel: {
options: {
sourceMap: true,
presets: ['es2015']
},
dist: {
files: {
2016-01-16 17:27:23 +01:00
'build/js/dist/Layout.js': 'build/js/src/Layout.js',
2015-11-11 20:29:54 +01:00
'build/js/dist/Treeview.js': 'build/js/src/Treeview.js',
'build/js/dist/PushMenu.js': 'build/js/src/PushMenu.js',
2016-01-16 17:27:23 +01:00
'build/js/dist/Widget.js': 'build/js/src/Widget.js',
'dist/js/adminlte.js': 'build/js/src/AdminLTE.js'
2015-11-04 19:51:10 +01:00
}
}
},
2015-11-11 20:29:54 +01:00
// Concat compiled JS files
concat: {
options: {
stripBanners: true,
banner: '<%= banner %>'
},
adminlte: {
src: [
2016-01-16 17:27:23 +01:00
'build/js/src/Layout.js',
'build/js/src/Treeview.js',
'build/js/src/PushMenu.js',
'build/js/src/Widget.js'
2015-11-11 20:29:54 +01:00
],
2016-01-16 17:27:23 +01:00
dest: 'build/js/src/AdminLTE.js'
2015-11-11 20:29:54 +01:00
}
},
2015-04-16 01:07:57 +02:00
// Build the documentation files
includes: {
build: {
2015-07-12 15:46:20 +02:00
src: ['*.html'], // Source files
dest: 'documentation/', // Destination directory
flatten: true,
cwd: 'documentation/build',
options: {
silent: true,
includePath: 'documentation/build/include'
2015-04-16 01:07:57 +02:00
}
}
},
// Optimize images
image: {
dynamic: {
2015-11-11 20:29:54 +01:00
files: [
{
expand: true,
cwd: 'build/img/',
src: ['**/*.{png,jpg,gif,svg,jpeg}'],
dest: 'dist/img/'
}
]
}
},
2015-11-11 20:29:54 +01:00
eslint: {
options: {
2015-11-11 20:29:54 +01:00
configFile: 'build/js/.eslintrc'
},
2015-11-11 20:29:54 +01:00
target: 'build/js/src/*.js'
},
// Lint JS code
jscs: {
options: {
config: 'build/js/.jscsrc'
},
2015-11-11 20:29:54 +01:00
grunt: {
src: ['Gruntfile.js']
},
2015-11-11 20:29:54 +01:00
core: {
src: 'js/src/*.js'
}
2015-11-11 20:29:54 +01:00
/*app: {
src: 'dist/js/app.js'
}*/
},
2015-08-22 19:22:37 +02:00
// Validate CSS files
2015-07-25 21:51:57 +02:00
csslint: {
options: {
2015-11-09 14:51:11 +01:00
csslintrc: 'build/scss/.csslintrc'
2015-07-25 21:51:57 +02:00
},
dist: [
2015-11-11 20:29:54 +01:00
'dist/css/AdminLTE.css'
2015-07-25 21:51:57 +02:00
]
},
2015-08-22 19:22:37 +02:00
// Validate Bootstrap HTML
bootlint: {
options: {
relaxerror: ['W005']
},
2016-01-16 17:27:23 +01:00
// files: ['pages/**/*.html', '*.html']
files: ['starter.html']
2015-08-22 19:22:37 +02:00
},
// Delete images in build directory
// After compressing the images in the build/img dir, there is no need
// for them
clean: {
2015-11-11 20:29:54 +01:00
build: ['build/img/*']
2015-02-01 22:25:09 +01:00
}
2015-11-11 20:29:54 +01:00
})
2015-04-16 01:07:57 +02:00
// Load all grunt tasks
2015-10-31 22:00:35 +01:00
// SASS compiler
2015-11-11 20:29:54 +01:00
grunt.loadNpmTasks('grunt-sass')
2015-04-16 01:07:57 +02:00
// Watch File Changes
2015-11-11 20:29:54 +01:00
grunt.loadNpmTasks('grunt-contrib-watch')
2015-04-16 01:07:57 +02:00
// Compress JS Files
2015-11-11 20:29:54 +01:00
grunt.loadNpmTasks('grunt-contrib-uglify')
2015-04-16 01:07:57 +02:00
// Include Files Within HTML
2015-11-11 20:29:54 +01:00
grunt.loadNpmTasks('grunt-includes')
// Optimize images
2015-11-11 20:29:54 +01:00
grunt.loadNpmTasks('grunt-image')
// Delete not needed files
2015-11-11 20:29:54 +01:00
grunt.loadNpmTasks('grunt-contrib-clean')
// Lint JS code
grunt.loadNpmTasks('grunt-jscs')
// Lint ECMA6 code
grunt.loadNpmTasks('grunt-eslint')
2015-07-25 21:51:57 +02:00
// Lint CSS
2015-11-11 20:29:54 +01:00
grunt.loadNpmTasks('grunt-contrib-csslint')
2015-08-22 19:22:37 +02:00
// Lint Bootstrap
2015-11-11 20:29:54 +01:00
grunt.loadNpmTasks('grunt-bootlint')
2015-11-04 19:51:10 +01:00
// Grunt Babel to compile ECMA6 to ECMA5
2015-11-11 20:29:54 +01:00
grunt.loadNpmTasks('grunt-babel')
// Concat files
grunt.loadNpmTasks('grunt-contrib-concat')
2015-08-22 19:22:37 +02:00
// Linting task
2015-11-11 20:29:54 +01:00
grunt.registerTask('lint', ['jscs', 'eslint', 'csslint', 'bootlint'])
// JS Build Task
grunt.registerTask('build-js', ['babel', 'concat', 'uglify'])
2015-04-16 01:07:57 +02:00
2015-11-11 20:29:54 +01:00
// The default task (running 'grunt' in console) is 'watch'
grunt.registerTask('default', ['watch'])
}