/
Gruntfile.js
103 lines (98 loc) · 3 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
/*jshint node: true */
/*global module:false */
module.exports = function(grunt) {
'use strict';
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-closurecompiler');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: {
jshintrc: ".jshintrc"
},
production: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
dev: {
options: {
devel:true
},
src: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js']
}
},
requirejs: {
snaps: {
options: {
dir:'tmp/',
logLevel:2,
baseUrl: 'src',
optimize: 'none',
modules: [{ name: "snaps" }]
}
}
},
clean: ["tmp", "dist"],
copy: {
dist: {
files: {
"dist/snaps.js": "tmp/snaps.js"
}
}
},
closurecompiler: {
options: {
compilation_level: "SIMPLE_OPTIMIZATIONS",
warning_level: 'DEFAULT',
summary_detail_level: 3
},
dist: {
src:'tmp/snaps.js',
dest:'dist/snaps.min.js'
}
},
mocha: {
options: {
mocha: {
ignoreLeaks: false
},
reporter:'Spec',
run: false
},
all: {
src: ["test/*.html"]
}
},
jsdoc : {
dist : {
src: ['src/**/*.js'],
options: {
destination: 'dist/doc',
private: false,
template: "./doc_template",
configure: './jsdoc.json'
}
}
},
watch: {
js: {
files: ['src/**/*.js'],
tasks: ['dev']
},
test: {
files: ['test/**/*.js','test/**/*.html'],
tasks: ['jshint:dev', 'test']
}
}
});
grunt.registerTask('dev', ['jshint:dev','requirejs:snaps','copy:dist']);
grunt.registerTask('production', ['jshint:production','requirejs:snaps','copy:dist','closurecompiler:dist']);
grunt.registerTask('default', ['production']);
grunt.registerTask('test', ['mocha:all']);
grunt.registerTask('doc', ['jsdoc:dist']);
grunt.registerTask('start', ['clean', 'dev', 'watch']);
grunt.registerTask('dist', ['clean', 'production', 'test', 'dev', 'doc']);
};