This repository was archived by the owner on Nov 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGruntfile.js
More file actions
129 lines (123 loc) · 3.21 KB
/
Gruntfile.js
File metadata and controls
129 lines (123 loc) · 3.21 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
/* jshint node: true */
module.exports = function (grunt) {
'use strict';
var pkg, vglVersion, templateData, port;
pkg = grunt.file.readJSON('package.json');
vglVersion = pkg.version;
port = Number(grunt.option('port') || '30101');
var sources = grunt.file.readJSON('sources.json'),
src = sources.vgl.prefix,
files = sources.vgl.files
.map(function (f) {
return src + '/' + f;
});
templateData = {
VGL_VERSION: vglVersion,
SOURCES_JSON: JSON.stringify(files),
SOURCES_ROOT: '/',
BUNDLE_EXT: 'built/vgl.ext.min.js'
};
grunt.config.init({
pkg: pkg,
clean: {
source: ['dist/src', 'src/version.js'],
all: ['dist', 'src/version.js']
},
concat: {
dist: {
src: files,
dest: 'dist/vgl.concat.js'
}
},
copy: {
vgl: {
src: files,
dest: 'dist/',
filter: 'isFile',
flatten: false
}
},
express: {
server: {
options: {
port: port,
server: 'testing/test-runners/server.js',
bases: ['dist']
}
}
},
template: {
version: {
options: {data: templateData},
files: {'src/version.js': 'src/version.js.in'}
},
loadDev: {
options: {data: templateData},
files: {'dist/built/vgl.all.dev.js': 'testing/vgl.all.dev.js.in'}
}
},
uglify: {
dist: {
files: {
'dist/vgl.min.js': 'dist/vgl.js'
},
options: {
mangle: true,
ASCIIOnly: true,
sourceMap: true
}
},
ext: {
files: {
'dist/built/vgl.ext.min.js': [
'node_modules/gl-matrix/dist/gl-matrix.js',
'node_modules/jquery/dist/jquery.js'
]
}
}
},
umd: {
dist: {
src: 'dist/vgl.concat.js',
dest: 'dist/vgl.js',
objectToExport: 'vgl',
amdModuleId: 'vgl'
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-express');
grunt.loadNpmTasks('grunt-parallel');
grunt.loadNpmTasks('grunt-template');
grunt.loadNpmTasks('grunt-umd');
grunt.registerTask(
'serve-test',
'Serve the content for testing. This starts on port 30101 by ' +
'default and does not rebuild sources automatically.',
function () {
grunt.config.set('express.server.options.hostname', '0.0.0.0');
if (!grunt.option('port')) {
grunt.config.set('express.server.options.port', 30101);
}
// make sure express doesn't change the port
var test_port = grunt.config.get('express.server.options.port');
grunt.event.on('express:server:started', function () {
if (grunt.config.get('express.server.options.port') !== test_port) {
grunt.fail.fatal('Port ' + test_port + ' unavailable.');
}
});
grunt.task.run(['express', 'express-keepalive']);
}
);
grunt.registerTask('default', [
'template',
'copy:vgl',
'concat',
'umd',
'uglify'
]);
};