mirror of https://github.com/ColorlibHQ/AdminLTE
Merge pull request #1082 from gitarno/feature/load-grunt-config
Feature/load grunt configpull/1005/head
commit
cd2293e814
215
Gruntfile.js
215
Gruntfile.js
|
@ -2,213 +2,28 @@
|
|||
|
||||
module.exports = function (grunt) {
|
||||
|
||||
'use strict'
|
||||
|
||||
grunt.initConfig({
|
||||
|
||||
// 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
|
||||
watch: {
|
||||
sass: {
|
||||
files: ['build/scss/*.scss', 'build/scss/skins/*.scss'],
|
||||
tasks: ['sass']
|
||||
},
|
||||
es6: {
|
||||
files: ['build/js/src/*.js'],
|
||||
tasks: ['concat', 'babel', 'uglify']
|
||||
},
|
||||
js: {
|
||||
files: ['dist/js/adminlte.js', 'dist/js/app.js'],
|
||||
tasks: ['uglify']
|
||||
}
|
||||
},
|
||||
|
||||
// SASS compiler
|
||||
sass: {
|
||||
development: {
|
||||
options: {
|
||||
style: 'expanded'
|
||||
},
|
||||
files: {
|
||||
'dist/css/AdminLTE.css': 'build/scss/AdminLTE.scss'
|
||||
}
|
||||
},
|
||||
production: {
|
||||
options: {
|
||||
style: 'compressed'
|
||||
},
|
||||
files: {
|
||||
'dist/css/adminlte.min.css': 'build/scss/AdminLTE.scss'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Compress the js files.
|
||||
uglify: {
|
||||
options: {
|
||||
mangle: true,
|
||||
preserveComments: 'some'
|
||||
},
|
||||
target: {
|
||||
files: {
|
||||
'dist/js/adminlte.min.js': ['dist/js/adminlte.js'],
|
||||
'dist/js/app.min.js': ['dist/js/app.js']
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Compile ES6
|
||||
babel: {
|
||||
options: {
|
||||
sourceMap: true,
|
||||
presets: ['es2015']
|
||||
},
|
||||
dist: {
|
||||
files: {
|
||||
'build/js/dist/Layout.js': 'build/js/src/Layout.js',
|
||||
'build/js/dist/Treeview.js': 'build/js/src/Treeview.js',
|
||||
'build/js/dist/PushMenu.js': 'build/js/src/PushMenu.js',
|
||||
'build/js/dist/Widget.js': 'build/js/src/Widget.js',
|
||||
'dist/js/adminlte.js': 'build/js/src/AdminLTE.js'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Concat compiled JS files
|
||||
concat: {
|
||||
options: {
|
||||
stripBanners: true,
|
||||
banner: '<%= banner %>'
|
||||
},
|
||||
adminlte: {
|
||||
src: [
|
||||
'build/js/src/Layout.js',
|
||||
'build/js/src/Treeview.js',
|
||||
'build/js/src/PushMenu.js',
|
||||
'build/js/src/Widget.js'
|
||||
],
|
||||
dest: 'build/js/src/AdminLTE.js'
|
||||
}
|
||||
},
|
||||
|
||||
// Build the documentation files
|
||||
includes: {
|
||||
build: {
|
||||
src: ['*.html'], // Source files
|
||||
dest: 'documentation/', // Destination directory
|
||||
flatten: true,
|
||||
cwd: 'documentation/build',
|
||||
options: {
|
||||
silent: true,
|
||||
includePath: 'documentation/build/include'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Optimize images
|
||||
image: {
|
||||
dynamic: {
|
||||
files: [
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'build/img/',
|
||||
src: ['**/*.{png,jpg,gif,svg,jpeg}'],
|
||||
dest: 'dist/img/'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
eslint: {
|
||||
options: {
|
||||
configFile: 'build/js/.eslintrc'
|
||||
},
|
||||
target: 'build/js/src/*.js'
|
||||
},
|
||||
|
||||
// Lint JS code
|
||||
jscs: {
|
||||
options: {
|
||||
config: 'build/js/.jscsrc'
|
||||
},
|
||||
grunt: {
|
||||
src: ['Gruntfile.js']
|
||||
},
|
||||
core: {
|
||||
src: 'js/src/*.js'
|
||||
}
|
||||
/*app: {
|
||||
src: 'dist/js/app.js'
|
||||
}*/
|
||||
},
|
||||
|
||||
// Validate CSS files
|
||||
csslint: {
|
||||
options: {
|
||||
csslintrc: 'build/scss/.csslintrc'
|
||||
},
|
||||
dist: [
|
||||
'dist/css/AdminLTE.css'
|
||||
]
|
||||
},
|
||||
|
||||
// Validate Bootstrap HTML
|
||||
bootlint: {
|
||||
options: {
|
||||
relaxerror: ['W005']
|
||||
},
|
||||
// files: ['pages/**/*.html', '*.html']
|
||||
files: ['starter.html']
|
||||
},
|
||||
|
||||
// Delete images in build directory
|
||||
// After compressing the images in the build/img dir, there is no need
|
||||
// for them
|
||||
clean: {
|
||||
build: ['build/img/*']
|
||||
'use strict';
|
||||
//loading the configurations and grunt tasks
|
||||
var configs = require('load-grunt-config')(grunt,{
|
||||
configPath: __dirname + '/grunt-tasks',
|
||||
data:{
|
||||
// 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'
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// Load all grunt tasks
|
||||
|
||||
// SASS compiler
|
||||
grunt.loadNpmTasks('grunt-sass')
|
||||
// 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')
|
||||
// Delete not needed files
|
||||
grunt.loadNpmTasks('grunt-contrib-clean')
|
||||
// Lint JS code
|
||||
grunt.loadNpmTasks('grunt-jscs')
|
||||
// Lint ECMA6 code
|
||||
grunt.loadNpmTasks('grunt-eslint')
|
||||
// Lint CSS
|
||||
grunt.loadNpmTasks('grunt-contrib-csslint')
|
||||
// Lint Bootstrap
|
||||
grunt.loadNpmTasks('grunt-bootlint')
|
||||
// Grunt Babel to compile ECMA6 to ECMA5
|
||||
grunt.loadNpmTasks('grunt-babel')
|
||||
// Concat files
|
||||
grunt.loadNpmTasks('grunt-contrib-concat')
|
||||
grunt.initConfig(configs);
|
||||
|
||||
// Linting task
|
||||
grunt.registerTask('lint', ['jscs', 'eslint', 'csslint', 'bootlint'])
|
||||
// JS Build Task
|
||||
grunt.registerTask('build-js', ['babel', 'concat', 'uglify'])
|
||||
|
||||
// The default task (running 'grunt' in console) is 'watch'
|
||||
grunt.registerTask('default', ['watch'])
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
// Compile ECMA6 to ECMA5
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
return {
|
||||
options: {
|
||||
sourceMap: true,
|
||||
presets: ['es2015']
|
||||
},
|
||||
dist: {
|
||||
files: {
|
||||
'build/js/dist/Layout.js': 'build/js/src/Layout.js',
|
||||
'build/js/dist/Treeview.js': 'build/js/src/Treeview.js',
|
||||
'build/js/dist/PushMenu.js': 'build/js/src/PushMenu.js',
|
||||
'build/js/dist/Widget.js': 'build/js/src/Widget.js',
|
||||
'dist/js/adminlte.js': 'build/js/src/AdminLTE.js'
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,12 @@
|
|||
// Validate Bootstrap HTML
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
return {
|
||||
options: {
|
||||
relaxerror: ['W005']
|
||||
},
|
||||
// files: ['pages/**/*.html', '*.html']
|
||||
files: ['starter.html']
|
||||
};
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
// Delete images in build directory
|
||||
// After compressing the images in the build/img dir, there is no need
|
||||
// for them
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
return {
|
||||
build: ["build/img/*"]
|
||||
};
|
||||
};
|
|
@ -0,0 +1,20 @@
|
|||
// Concat compiled JS files
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
return {
|
||||
options: {
|
||||
stripBanners: true,
|
||||
banner: '<%= banner %>'
|
||||
},
|
||||
adminlte: {
|
||||
src: [
|
||||
'build/js/src/Layout.js',
|
||||
'build/js/src/Treeview.js',
|
||||
'build/js/src/PushMenu.js',
|
||||
'build/js/src/Widget.js'
|
||||
],
|
||||
dest: 'build/js/src/AdminLTE.js'
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,14 @@
|
|||
// Validate CSS files
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
return {
|
||||
options: {
|
||||
csslintrc: 'build/less/.csslintrc'
|
||||
},
|
||||
dist: [
|
||||
'dist/css/AdminLTE.css',
|
||||
]
|
||||
}
|
||||
|
||||
};
|
|
@ -0,0 +1,11 @@
|
|||
// Lint ECMASCRIPT
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
return {
|
||||
options: {
|
||||
configFile: 'build/js/.eslintrc'
|
||||
},
|
||||
target: 'build/js/src/*.js'
|
||||
};
|
||||
};
|
|
@ -0,0 +1,15 @@
|
|||
// Optimize images
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
return {
|
||||
dynamic: {
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: 'build/img/',
|
||||
src: ['**/*.{png,jpg,gif,svg,jpeg}'],
|
||||
dest: 'dist/img/'
|
||||
}]
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,17 @@
|
|||
// Build the documentation files
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
return {
|
||||
build: {
|
||||
src: ['*.html'], // Source files
|
||||
dest: 'documentation/', // Destination directory
|
||||
flatten: true,
|
||||
cwd: 'documentation/build',
|
||||
options: {
|
||||
silent: true,
|
||||
includePath: 'documentation/build/include'
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
// Lint JS code
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
return {
|
||||
options: {
|
||||
config: 'build/js/.jscsrc'
|
||||
},
|
||||
grunt: {
|
||||
src: ['Gruntfile.js']
|
||||
},
|
||||
core: {
|
||||
src: 'js/src/*.js'
|
||||
}
|
||||
/*app: {
|
||||
src: 'dist/js/app.js'
|
||||
}*/
|
||||
};
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
// Validate JS code
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
return {
|
||||
options: {
|
||||
jshintrc: '.jshintrc'
|
||||
},
|
||||
core: {
|
||||
src: 'dist/js/app.js'
|
||||
},
|
||||
demo: {
|
||||
src: 'dist/js/demo.js'
|
||||
},
|
||||
pages: {
|
||||
src: 'dist/js/pages/*.js'
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,24 @@
|
|||
// SASS compiler
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
return {
|
||||
development: {
|
||||
options: {
|
||||
style: 'expanded'
|
||||
},
|
||||
files: {
|
||||
'dist/css/AdminLTE.css': 'build/scss/AdminLTE.scss'
|
||||
}
|
||||
},
|
||||
production: {
|
||||
options: {
|
||||
style: 'compressed'
|
||||
},
|
||||
files: {
|
||||
'dist/css/adminlte.min.css': 'build/scss/AdminLTE.scss'
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,17 @@
|
|||
// Uglify task info. Compress the js files.
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
return {
|
||||
options: {
|
||||
mangle: true,
|
||||
preserveComments: 'some'
|
||||
},
|
||||
target: {
|
||||
files: {
|
||||
'dist/js/adminlte.min.js': ['dist/js/adminlte.js'],
|
||||
'dist/js/app.min.js': ['dist/js/app.js']
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
// Watch files for changes and invoke appropriate compiler
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
return {
|
||||
sass: {
|
||||
files: ['build/scss/*.scss', 'build/scss/skins/*.scss'],
|
||||
tasks: ['sass']
|
||||
},
|
||||
es6: {
|
||||
files: ['build/js/src/*.js'],
|
||||
tasks: ['concat', 'babel', 'uglify']
|
||||
},
|
||||
js: {
|
||||
files: ['dist/js/adminlte.js', 'dist/js/app.js'],
|
||||
tasks: ['uglify']
|
||||
}
|
||||
};
|
||||
};
|
|
@ -44,7 +44,7 @@
|
|||
"grunt-image": "^1.0.5",
|
||||
"grunt-includes": "^0.4.5",
|
||||
"grunt-jscs": "^2.3.0",
|
||||
"grunt-sass": "^1.1.0",
|
||||
"grunt-scss-lint": "^0.3.8"
|
||||
"grunt-scss-lint": "^0.3.8",
|
||||
"load-grunt-config": "^0.19.2"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue