forked from ableplayer/ableplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
185 lines (182 loc) · 5.49 KB
/
Gruntfile.js
File metadata and controls
185 lines (182 loc) · 5.49 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
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
module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-cssmin");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-remove-logging");
grunt.loadNpmTasks("grunt-decomment");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-terser");
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
concat: {
options: {
banner: "/*! <%= pkg.name %> V<%= pkg.version %> with DOMPurify included */\n",
process: function(src, filepath) {
// Remove the source map reference line only from the dompurify file
if (filepath.includes('dompurify')) {
return src.replace(/\/\/# sourceMappingURL=.*\.map/g, '');
}
return src;
}
},
build: {
src: [
"node_modules/dompurify/dist/purify.js",
"scripts/ableplayer-base.js",
"scripts/initialize.js",
"scripts/preference.js",
"scripts/webvtt.js",
"scripts/buildplayer.js",
"scripts/validate.js",
"scripts/track.js",
"scripts/youtube.js",
"scripts/slider.js",
"scripts/volume.js",
"scripts/dialog.js",
"scripts/misc.js",
"scripts/description.js",
"scripts/browser.js",
"scripts/control.js",
"scripts/caption.js",
"scripts/chapters.js",
"scripts/metadata.js",
"scripts/transcript.js",
"scripts/search.js",
"scripts/event.js",
"scripts/dragdrop.js",
"scripts/sign.js",
"scripts/langs.js",
"scripts/translation.js",
"scripts/vts.js",
"scripts/vimeo.js",
],
dest: "build/<%= pkg.name %>.js",
},
build_separate_dompurify: {
options: {
banner: "/*! <%= pkg.name %> V<%= pkg.version %> - In this file, DOMPurify is not bundled in with AblePlayer, but is a required dependency that can be added to the project via a local copy or a CDN */\n",
},
src: [
"scripts/ableplayer-base.js",
"scripts/initialize.js",
"scripts/preference.js",
"scripts/webvtt.js",
"scripts/buildplayer.js",
"scripts/validate.js",
"scripts/track.js",
"scripts/youtube.js",
"scripts/slider.js",
"scripts/volume.js",
"scripts/dialog.js",
"scripts/misc.js",
"scripts/description.js",
"scripts/browser.js",
"scripts/control.js",
"scripts/caption.js",
"scripts/chapters.js",
"scripts/metadata.js",
"scripts/transcript.js",
"scripts/search.js",
"scripts/event.js",
"scripts/dragdrop.js",
"scripts/sign.js",
"scripts/langs.js",
"scripts/translation.js",
"scripts/vts.js",
"scripts/vimeo.js",
],
dest: "build/separate-dompurify/<%= pkg.name %>.js",
},
},
removelogging: {
dist: {
src: ["build/<%= pkg.name %>.js"],
dest: "build/<%= pkg.name %>.dist.js",
},
dist_separate_dompurify: {
src: ["build/separate-dompurify/<%= pkg.name %>.js"],
dest: "build/separate-dompurify/<%= pkg.name %>.dist.js",
},
options: {
// Remove all console output (see https://www.npmjs.com/package/grunt-remove-logging)
},
},
decomment: {
any: {
options: {
safe: true,
},
files: {
"build/<%= pkg.name %>.dist.js": "build/<%= pkg.name %>.dist.js",
},
}
},
terser: {
min: {
files: {
"build/<%= pkg.name %>.min.js": ["build/<%= pkg.name %>.dist.js"],
},
options: {
ecma: 2015, // Specify ECMAScript version to support ES6+
keep_fnames: true,
output: {
comments: /^!/,
},
},
},
min_separate_dompurify: {
files: {
"build/separate-dompurify/<%= pkg.name %>.min.js": ["build/separate-dompurify/<%= pkg.name %>.dist.js"],
"build/separate-dompurify/purify.min.js": ["node_modules/dompurify/dist/purify.js"],
},
options: {
ecma: 2015, // Specify ECMAScript version to support ES6+
keep_fnames: true,
output: {
comments: /^!/,
},
},
},
},
cssmin: {
min: {
src: ["styles/ableplayer.css"],
dest: "build/<%= pkg.name %>.min.css",
},
options: {
// Add a banner with the package name and version
// (no date, otherwise a new build is different even if the code didn't change!)
// (oddly, here we don't need a '\n' at the end!)
banner: "/*! <%= pkg.name %> V<%= pkg.version %> */",
},
},
jshint: {
files: ["Gruntfile.js", "scripts/**/*.js"],
options: {
// options here to override JSHint defaults
globals: {
browser: true,
jquery: true,
devel: true,
},
},
},
clean: {
build: ["build"],
},
});
grunt.registerTask("default", [
"concat:build",
"removelogging:dist",
"decomment",
"terser:min",
"cssmin",
]);
grunt.registerTask("build_separate_dompurify", [
"concat:build_separate_dompurify",
"removelogging:dist_separate_dompurify",
"terser:min_separate_dompurify",
]);
grunt.registerTask("test", ["jshint"]);
};