-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathGruntfile.js
More file actions
109 lines (107 loc) · 3.59 KB
/
Copy pathGruntfile.js
File metadata and controls
109 lines (107 loc) · 3.59 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
'use strict';
var path = require('path');
var require_transform = require('./transforms/require-transform.js');
function absolute(a){
if (Array.isArray(a))
return a.map(function(r){ return path.join(__dirname, r); });
var ret = {};
Object.keys(a).forEach(function(r){
ret[path.join(__dirname, r)] = a[r]; });
return ret;
}
module.exports = function(grunt) {
require('time-grunt')(grunt);
var pkg = grunt.file.readJSON('package.json');
grunt.initConfig({
pkg: pkg,
clean: {
dist: ['dist/*'],
},
jshint: {
options: {jshintrc: '.jshintrc'},
all: ['src/*.js', './*.js'],
},
browserify: {
options: {
browserifyOptions: {
debug: true,
noParse: absolute([
// avoid it requiring its own videojs
'./node_modules/videojs-ima/src/videojs.ima.js',
// for faster build
'./node_modules/video.js/dist/video.js',
'./node_modules/jquery-browserify/lib/jquery.js',
]),
},
transform: [
['browserify-versionify', {
placeholder: '__VERSION__',
version: pkg.version,
}],
'browserify-css',
[require_transform, {
global: true,
shims: absolute({
'./node_modules/videojs-ima/src/videojs.ima.js': {
'video.js': 'window.videojs',
'videojs-contrib-ads': 'null',
},
}),
}],
],
},
watch: {
options: {
watch: true,
keepAlive: true,
},
files: {'dist/hola_player.dev.js': ['src/hola_player.js']},
},
dist: {
files: {'dist/hola_player.dev.js': ['src/hola_player.js']},
},
},
exorcise: {
dist: {
options: {},
files: {
'dist/hola_player.dev.js.map': ['dist/hola_player.dev.js'],
},
},
},
copy: {
videojs: {
src: 'node_modules/@hola.org/videojs-swf/dist/video-js.swf',
dest: 'dist/videojs.swf',
},
'videojs-osmf': {
src: 'node_modules/@hola.org/videojs-osmf/dist/videojs-osmf.swf',
dest: 'dist/videojs-osmf.swf',
},
},
uglify : {
options: {
sourceMap: true,
sourceMapIn: 'dist/hola_player.dev.js.map',
},
dist : {
files: {'dist/hola_player.js' : 'dist/hola_player.dev.js'},
},
},
zip: {
dist: {
router: function(filepath){
if (path.extname(filepath)=='.zip')
return null;
return path.relative('dist', filepath);
},
src: ['dist/**/*'],
dest: 'dist/hola-player-'+ pkg.version+'.zip'
},
},
});
require('load-grunt-tasks')(grunt);
grunt.registerTask('build', ['clean', 'jshint', 'browserify:dist',
'exorcise', 'copy', 'uglify', 'zip']);
grunt.registerTask('default', ['build']);
};