forked from morrissinger/BootstrapTreeNav
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
177 lines (157 loc) · 4.98 KB
/
Gruntfile.js
File metadata and controls
177 lines (157 loc) · 4.98 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
module.exports = function (grunt) {
'use strict';
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
jqueryCheck: 'if (!jQuery) { throw new Error(\"Bootstrap Tree Nav requires jQuery\"); }\n\n',
banner: '/**\n' +
'* <%= pkg.name %>.js v<%= pkg.version %> \n' +
'* Copyright <%= grunt.template.today("yyyy") %> <%= pkg.contributors[0].name %>\n' +
'* Copyright 2013 <%= pkg.author %> by @morrissinger\n' +
'* License: <%= pkg.license %>\n' +
'*/\n',
// Task configuration.
clean: {
dist: ['dist']
},
jshint: {
options: {
jshintrc: 'js/.jshintrc'
},
gruntfile: {
src: 'Gruntfile.js'
},
src: {
src: [
'js/lang/*/*.js',
'js/*.js',
'tests/*.js',
'tests/libs/prototypes.js'
]
}
},
concat: {
options: {
stripBanners: false
},
bootstraptreenav: {
src: [
'js/*.js'
],
dest: 'dist/js/<%= pkg.name %>.js'
}
},
uglify: {
options: {
},
bootstraptreenav: {
src: ['<%= concat.bootstraptreenav.dest %>'],
dest: 'dist/js/<%= pkg.name %>.min.js'
}
},
copy: {
img: {
expand: true,
src: ['img/*'],
dest: 'dist/'
}
},
sass: {
src: {
options: {
style: 'expanded',
},
files: {
'dist/css/bootstrap-treenav.css' : 'sass/bootstrap-treenav.scss'
}
},
dist: {
options: {
style: 'compressed',
},
files: {
'dist/css/bootstrap-treenav.min.css' : 'sass/bootstrap-treenav.scss'
}
}
},
watch: {
src: {
files: '<%= jshint.src.src %>',
tasks: ['jshint:src']
},
css: {
files: '**/*.scss',
tasks: ['sass']
}
},
usebanner: {
options: {
position: 'top',
banner: '<%= banner %>',
linebreak: true
},
files: {
src: ['dist/js/*.js','dist/css/*.css']
}
},
// Mocha
mocha: {
all: {
src: ['tests/testrunner.html'],
},
options: {
timeout: 10000,
log: true,
reporter: 'Spec', /* [1] */
run: true /* [2] */
}
},
htmlhintplus: {
options: {
htmlhintrc: 'js/.htmlhintrc',
//Como no es crucial el estilo del test ni el ejemplo, no rompera la compilacion si hay algun error en el html.
force: true,
newer: true
},
build: {
options: {
force: false
},
src: [
'example/*.html',
'tests/*.html'
]
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-banner');
grunt.loadNpmTasks('grunt-htmlhint-plus');
// Banner task.
grunt.registerTask('banner', ['usebanner']);
// JS distribution task.
grunt.registerTask('dist-js', ['concat', 'uglify']);
// CSS distribution task.
grunt.registerTask('dist-css', ['sass']);
// Img distribution task.
grunt.registerTask('dist-img', ['copy']);
//Tests with mocha
grunt.registerTask('unittest', ['mocha']);
//For testing purposes
var testSubtasks = ['dist-css', 'jshint', 'unittest', 'htmlhintplus'];
//Set of tasks to test the solution
grunt.registerTask('test', testSubtasks);
// Full distribution task.
grunt.registerTask('dist', ['clean', 'dist-css', 'dist-img', 'dist-js', 'banner']);
// Default task.
grunt.registerTask('default', ['test', 'dist']);
};