-
Notifications
You must be signed in to change notification settings - Fork 52
/
Gruntfile.js
151 lines (145 loc) · 4.31 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
(function () {
module.exports = function () {
var banner =
"/*! <%= pkg.title %> <%= pkg.homepage %> - v<%= pkg.version %> - <%= grunt.template.today('yyyy-mm-dd') %> (<%= grunt.template.date('longTime') %>)\n* Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>; Licensed MIT, AGPL. */\n";
var grunt = this;
// Project configuration.
this.initConfig({
pkg: this.file.readJSON('package.json'),
concat: {
options: {
stripBanners: true,
banner: banner,
},
dist: {
src: [
// Libs
'libs/underscore.js',
'libs/backbone.js',
'libs/backbone.localStorage.js',
'libs/mousetrap.js',
'libs/spectrum/spectrum.js',
'libs/jquery.ui.touch-punch.js',
'libs/jquery.ui.touch-punch.js',
'libs/js-expression-eval/parser.js',
// Before
'src/plugins/github-api.js',
// Iframework
'src/iframework.js',
'src/iframework-utils.js',
'src/eventshistory.js',
'src/local-app.js',
'src/local-app-view.js',
'src/graph.js',
'src/graph-view.js',
'src/node.js',
'src/node-view.js',
'src/node-box.js',
'src/node-box-view.js',
'src/node-box-native-view.js',
'src/node-box-iframe.js',
'src/node-box-iframe-view.js',
'src/port.js',
'src/port-view.js',
'src/port-in.js',
'src/port-in-view.js',
'src/port-out.js',
'src/port-out-view.js',
'src/module.js',
'src/module-view.js',
'src/edge.js',
'src/edge-view.js',
'src/router.js',
// Nodes (most are loaded dynamically)
'src/nodes/image.js',
// Plugins
'src/plugins/source.js',
'src/plugins/library.js',
'src/plugins/images.js',
// 'src/plugins/towtruck.js',
// All Iframework loaded
'src/iframework-last.js',
],
dest: 'build/<%= pkg.name %>.js',
},
},
uglify: {
options: {
banner: banner,
report: 'min',
},
dist: {
files: {
'build/<%= pkg.name %>.min.js': ['build/<%= pkg.name %>.js'],
},
},
},
jshint: {
all: [
'Gruntfile.js',
'src/*.js',
'src/**/*.js',
'!src/nodes/webgl-sphere.js',
],
options: {
esversion: 11,
browser: true,
sub: true,
globals: {
// "console": true,
_: true,
$: true,
jQuery: true,
Backbone: true,
yepnope: true,
Iframework: true,
Mousetrap: true,
},
},
force: {
options: {force: true},
files: {
src: [
'Gruntfile.js',
'src/*.js',
'src/**/*.js',
'!src/nodes/webgl-sphere.js',
],
},
},
},
connect: {
options: {
port: 8000,
hostname: '*', // available from ipaddress:8000 on same network (or name.local:8000)
},
uses_defaults: {},
},
watch: {
scripts: {
files: ['Gruntfile.js', 'src/*.js', 'src/**/*.js'],
tasks: ['jshint:force'],
options: {
nospawn: true,
},
},
},
});
// Only lint the changed file when watching
this.event.on('watch', function (action, filepath) {
grunt.config('jshint.force.files.src', filepath);
});
// grunt.event.on('jshint:lint', function() {
// grunt.warn();
// });
this.loadNpmTasks('grunt-contrib-concat');
this.loadNpmTasks('grunt-contrib-uglify');
this.loadNpmTasks('grunt-contrib-jshint');
this.loadNpmTasks('grunt-contrib-connect');
this.loadNpmTasks('grunt-contrib-watch');
this.registerTask('dev', ['connect', 'watch']);
this.registerTask('build', ['concat:dist', 'uglify:dist']);
this.registerTask('test', ['jshint:all']);
this.registerTask('default', ['test', 'build']);
};
}).call(this);