-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
134 lines (112 loc) · 3.39 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
var childProcess = require('child_process');
module.exports = function(grunt) {
// ========================================================================
// Configure task options
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
css: [
'css/*.css',
'tmp/css/*.css'
],
'js': [
'js/jmychampolion*.js'
]
},
lesslint: {
src: ['src/less/*.less']
},
less: {
files: {
expand: true,
flatten: true,
cwd: "src/less/",
src: "*.less",
dest: "tmp/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'
}
},
concat: {
dist_full: {
src: [
'js/libs/*.js',
'src/js/*.js',
'!js/libs/jmyloader-full-min.js'
],
dest: 'js/jmychampolion-withlibs.js'
},
dist_nolibs: {
src: [
'src/js/*.js'
],
dest: 'js/jmychampolion.js'
},
dist_css: {
src: [
'tmp/css/*.css'
],
dest: 'css/jmychampolion.css'
}
},
uglify: {
build_full: {
src: 'js/jmychampolion-withlibs.js',
dest: 'js/jmychampolion-withlibs.min.js'
},
build_nolibs: {
src: 'js/jmychampolion.js',
dest: 'js/jmychampolion.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-concat');
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', 'concat:dist_css', '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', 'concat', 'cssmin', 'uglify']);
};