-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
102 lines (81 loc) · 2.66 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
var childProcess = require('child_process');
module.exports = function(grunt) {
// ========================================================================
// Configure task options
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
css: [
'css/*.css'
]
},
lesslint: {
src: ['src/less/*.less']
},
less: {
files: {
expand: true,
flatten: true,
cwd: "src/less/",
src: "*.less",
dest: "css",
ext: ".css"
}
},
cssmin: {
options: {
banner: '/**!\n * @name\t\t<%= pkg.name %>\n * @version\t\tv<%= pkg.version %>\n * ' +
'@date\t\t<%= grunt.template.today("yyyy-mm-dd") %>\n * @copyright\t<%= pkg.copyright %>\n * @source\t\t<%= pkg.repository %>\n * @license\t\t<%= pkg.license %>\n */\n',
footer: '/* @license-end */'
},
minify: {
expand: true,
cwd: 'css/',
src: ['*.css', '!*.min.css'],
dest: 'css/',
ext: '.min.css'
}
},
uglify: {
build: {
src: 'js/jmypuzzle.js',
dest: 'js/jmypuzzle.min.js'
}
},
watch: {
less: {
files: ['Gruntfile.js', 'package.json', 'src/less/*.less','src/less/**/*.less'],
tasks: ['css'],
options: {
spawn: false
}
}
}
});
// on watch events configure jshint:all to only run on changed file
// grunt.event.on('watch', function(action, filepath) {
// grunt.config(['jshint', 'all'], filepath);
// });
// ========================================================================
// Initialise
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-lesslint');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-shell');
// ========================================================================
// Register Tasks
// Run 'grunt test' to view lesslint recommendations
grunt.registerTask('test', ['lesslint']);
// Run 'grunt csslint' to check LESS quality, and if no errors then
// compile LESS into CSS, combine and minify
grunt.registerTask('csslint', ['lesslint', 'clean:css', 'less', 'cssmin']);
// Run 'grunt css' to compile LESS into CSS, combine and minify
grunt.registerTask('css', ['clean:css', 'less', 'cssmin']);
// 'grunt' will check code quality, and if no errors,
// compile LESS to CSS, and minify and concatonate all JS and CSS
grunt.registerTask('default', [ 'clean', 'less', 'cssmin', 'uglify']);
};