forked from mediaelement/mediaelement
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
207 lines (199 loc) · 8.21 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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks("grunt-remove-logging");
var featureSources;
// if commandline list of features, (e.g. --features=playpause,stop,...) build only these included
var featureList = grunt.option('features');
if (featureList) {
featureList = featureList.split(',');
featureSources = [];
featureList.forEach(function(feature) {
var path = 'src/js/mep-feature-' + feature + '.js';
if (grunt.file.isFile(path)) {
featureSources.push(path);
}
})
}
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
me: {
src: [
'src/js/me-header.js',
'src/js/me-namespace.js',
'src/js/me-utility.js',
'src/js/me-plugindetector.js',
'src/js/me-featuredetection.js',
'src/js/me-mediaelements.js',
'src/js/me-shim.js',
'src/js/me-i18n.js',
'src/js/me-i18n-locale-en.js'
],
dest: 'build/mediaelement.js'
},
mep: {
src: [
'src/js/mep-header.js',
'src/js/mep-library.js',
'src/js/mep-player.js'
].concat(featureSources || [
'src/js/mep-feature-playpause.js',
'src/js/mep-feature-stop.js',
'src/js/mep-feature-progress.js',
'src/js/mep-feature-time.js',
'src/js/mep-feature-volume.js',
'src/js/mep-feature-fullscreen.js',
'src/js/mep-feature-speed.js',
'src/js/mep-feature-tracks.js',
'src/js/mep-feature-sourcechooser.js',
'src/js/mep-feature-contextmenu.js',
'src/js/mep-feature-skipback.js',
'src/js/mep-feature-postroll.js',
'src/js/mep-feature-markers.js'
]),
dest: 'build/mediaelementplayer.js'
},
bundle: {
src: [
'build/mediaelement.js',
'build/mediaelementplayer.js'
],
dest: 'build/mediaelement-and-player.js'
}
},
removelogging: {
dist: {
src: [
'build/mediaelement.js',
'build/mediaelementplayer.js',
'build/mediaelement-and-player.js'
]
},
options: {
// Keep `warn` and other methods from the console API
methods: ['log']
}
},
uglify: {
me: {
src : ['build/mediaelement.js'],
dest : 'build/mediaelement.min.js',
banner : 'src/js/me-header.js'
},
mep: {
src : ['build/mediaelementplayer.js'],
dest : 'build/mediaelementplayer.min.js',
banner : 'src/js/mep-header.js'
},
bundle: {
src : ['build/mediaelement-and-player.js'],
dest : 'build/mediaelement-and-player.min.js'
},
options: {
// Preserve comments that start with a bang (like the file header)
preserveComments: "some"
}
},
cssmin: {
build: {
src : ['src/css/mediaelementplayer.css'],
dest : 'build/mediaelementplayer.min.css'
}
},
copy: {
build: {
expand : true,
cwd : 'src/css/',
src : ['*.png', '*.svg', '*.gif', '*.css'],
dest : 'build/',
flatten : true,
filter : 'isFile'
},
translation: {
expand : true,
cwd : 'src/js/',
src : ['me-i18n-locale-*.js'],
dest : 'build/lang',
flatten : true,
filter : 'isFile'
}
},
clean: {
build: ['build'],
temp: ['tmp']
},
// Task that compiles flashmediaelement.swf using the free Flex SDK on Linux/Mac.
// There are a few prerequisite steps involved in running this task.
//
// 1) Install the Flex SDK version 4.6 (only needs to be done once)
// Download the free flex sdk from http://sourceforge.net/adobe/flexsdk/wiki/Download%20Flex%204.6/
// Unzip it to a directory on your local machine (eg: /usr/local/flex_sdk_4.6)
// Create a symlink from the install location to this directory
// (eg: ln -s /usr/local/flex_sdk_4.6 mediaelement/src/flash)
//
// 2) Update the `flexPath` variable below to reflect the name of the symlink you created
//
// 3) Build the SWC file (only needs to be done if you have changed something in the FLA file)
// Open the FlashMediaElement.fla file in the Flash Professional IDE.
// Goto the menu item 'File->Publish Settings'
// Click the 'Flash' tab
// Make sure the box 'Export SWC' is checked
// Click 'Publish'
// Quit out of the Flash IDE
//
// 4) Run this task from the command line: `grunt shell:buildFlash`
//
// Note: There doesn't seem to be an available SWC library that defines the YouTube player API.
// Remove the -strict compiler option to see warnings coming from YouTube API calls.
//
flexPath: '../flex_sdk_4.6',
buildFlashCommand: [
'<%= flexPath %>/bin/mxmlc -strict=false -compiler.debug -warnings=true',
'src/flash/FlashMediaElement.as -o <%= flashOut %>',
'-define+=CONFIG::cdnBuild,<%= cdnBuild %>',
'-define+=CONFIG::debugBuild,<%= debugBuild %>',
'-library-path+="<%= flexPath %>/lib"',
'-include-libraries+=src/flash/flashmediaelement.swc',
'-include-libraries+=src/flash/flashls.swc -use-network=true',
'-source-path src/flash',
'-target-player 10.0',
'-headless-server -static-link-runtime-shared-libraries'
].join(" "),
shell: {
buildFlash: {
command: function() {
grunt.config.set("cdnBuild", 'false');
grunt.config.set("debugBuild", 'false');
grunt.config.set("flashOut", 'build/flashmediaelement.swf');
return grunt.config.get("buildFlashCommand");
}
},
buildFlashCDN: {
command: function() {
grunt.config.set("cdnBuild", 'true');
grunt.config.set("debugBuild", 'false');
grunt.config.set("flashOut", 'build/flashmediaelement-cdn.swf');
return grunt.config.get("buildFlashCommand");
}
},
buildFlashDebug: {
command: function() {
grunt.config.set("cdnBuild", 'true');
grunt.config.set("debugBuild", 'true');
grunt.config.set("flashOut", 'build/flashmediaelement-debug.swf');
return grunt.config.get("buildFlashCommand");
}
}
}
});
grunt.registerTask('default', ['concat', 'removelogging', 'uglify', 'cssmin', 'copy',
'shell:buildFlash', 'shell:buildFlashCDN', 'shell:buildFlashDebug', 'clean:temp']);
grunt.registerTask('html5only', ['concat', 'removelogging', 'uglify', 'cssmin', 'copy', 'clean:temp']);
grunt.registerTask('debug_html5', ['concat', 'uglify', 'cssmin', 'copy', 'clean:temp']);
};