11module . exports = function ( grunt ) {
2- grunt . loadNpmTasks ( "grunt-contrib-concat" ) ;
3- grunt . loadNpmTasks ( "grunt-contrib-copy" ) ;
42 grunt . loadNpmTasks ( "grunt-contrib-cssmin" ) ;
53 grunt . loadNpmTasks ( "grunt-contrib-clean" ) ;
6- grunt . loadNpmTasks ( "grunt-remove-logging" ) ;
7- grunt . loadNpmTasks ( "grunt-decomment" ) ;
8- grunt . loadNpmTasks ( "grunt-contrib-jshint" ) ;
94 grunt . loadNpmTasks ( "grunt-terser" ) ;
105 grunt . loadNpmTasks ( 'grunt-run' ) ;
6+ grunt . loadNpmTasks ( 'grunt-eslint' ) ;
117
128 grunt . initConfig ( {
139 pkg : grunt . file . readJSON ( "package.json" ) ,
14- concat : {
15- options : {
16- banner : "/*! <%= pkg.name %> V<%= pkg.version %> with DOMPurify included */\n" ,
17- process : function ( src , filepath ) {
18- // Remove the source map reference line only from the dompurify file
19- if ( filepath . includes ( 'dompurify' ) ) {
20- return src . replace ( / \/ \/ # s o u r c e M a p p i n g U R L = .* \. m a p / g, '' ) ;
21- }
22- return src ;
23- }
24- } ,
25- build : {
26- src : [
27- "node_modules/dompurify/dist/purify.js" ,
28- "scripts/ableplayer-base.js" ,
29- "scripts/initialize.js" ,
30- "scripts/preference.js" ,
31- "scripts/webvtt.js" ,
32- "scripts/buildplayer.js" ,
33- "scripts/validate.js" ,
34- "scripts/track.js" ,
35- "scripts/youtube.js" ,
36- "scripts/slider.js" ,
37- "scripts/volume.js" ,
38- "scripts/dialog.js" ,
39- "scripts/misc.js" ,
40- "scripts/description.js" ,
41- "scripts/browser.js" ,
42- "scripts/control.js" ,
43- "scripts/caption.js" ,
44- "scripts/chapters.js" ,
45- "scripts/metadata.js" ,
46- "scripts/transcript.js" ,
47- "scripts/search.js" ,
48- "scripts/event.js" ,
49- "scripts/dragdrop.js" ,
50- "scripts/sign.js" ,
51- "scripts/langs.js" ,
52- "scripts/translation.js" ,
53- "scripts/vts.js" ,
54- "scripts/vimeo.js" ,
55- ] ,
56- dest : "build/<%= pkg.name %>.js" ,
57- } ,
58- build_separate_dompurify : {
59- options : {
60- 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" ,
61- } ,
62- src : [
63- "scripts/ableplayer-base.js" ,
64- "scripts/initialize.js" ,
65- "scripts/preference.js" ,
66- "scripts/webvtt.js" ,
67- "scripts/buildplayer.js" ,
68- "scripts/validate.js" ,
69- "scripts/track.js" ,
70- "scripts/youtube.js" ,
71- "scripts/slider.js" ,
72- "scripts/volume.js" ,
73- "scripts/dialog.js" ,
74- "scripts/misc.js" ,
75- "scripts/description.js" ,
76- "scripts/browser.js" ,
77- "scripts/control.js" ,
78- "scripts/caption.js" ,
79- "scripts/chapters.js" ,
80- "scripts/metadata.js" ,
81- "scripts/transcript.js" ,
82- "scripts/search.js" ,
83- "scripts/event.js" ,
84- "scripts/dragdrop.js" ,
85- "scripts/sign.js" ,
86- "scripts/langs.js" ,
87- "scripts/translation.js" ,
88- "scripts/vts.js" ,
89- "scripts/vimeo.js" ,
90- ] ,
91- dest : "build/separate-dompurify/<%= pkg.name %>.js" ,
92- } ,
93- } ,
94- removelogging : {
95- dist : {
96- src : [ "build/<%= pkg.name %>.js" ] ,
97- dest : "build/<%= pkg.name %>.dist.js" ,
98- } ,
99- dist_separate_dompurify : {
100- src : [ "build/separate-dompurify/<%= pkg.name %>.js" ] ,
101- dest : "build/separate-dompurify/<%= pkg.name %>.dist.js" ,
102- } ,
103- options : {
104- // Remove all console output (see https://www.npmjs.com/package/grunt-remove-logging)
105- } ,
106- esm : {
107- options : {
108- methods : [ 'log' ] ,
109- files : {
110- "build/<%= pkg.name %>.esm.js" : [ "build/<%= pkg.name %>.esm.js" ] ,
111- }
112- }
113- } ,
114- } ,
115- decomment : {
116- any : {
117- options : {
118- safe : true ,
119- } ,
120- files : {
121- "build/<%= pkg.name %>.dist.js" : "build/<%= pkg.name %>.dist.js" ,
122- } ,
123-
124- }
125- } ,
126- terser : {
127- options : {
128- ecma : 2015 ,
129- keep_fnames : true ,
130- format : {
131- comments : / ^ ! / ,
132- }
133- } ,
134- min : {
135- files : {
136- "build/<%= pkg.name %>.min.js" : [ "build/<%= pkg.name %>.dist.js" ] ,
137- } ,
138- } ,
139- min_separate_dompurify : {
140- files : {
141- "build/separate-dompurify/<%= pkg.name %>.min.js" : [ "build/separate-dompurify/<%= pkg.name %>.dist.js" ] ,
142- "build/separate-dompurify/purify.min.js" : [ "node_modules/dompurify/dist/purify.js" ] ,
143- } ,
144- } ,
145- umd : {
146- options : {
147- compress : {
148- 'drop_console' : [ 'log' ]
149- }
150- } ,
151- files : {
152- "build/<%= pkg.name %>.umd.min.js" : [ "build/<%= pkg.name %>.umd.js" ]
153- }
154- } ,
155- umd_separate_dompurify : {
156- options : {
157- compress : {
158- 'drop_console' : [ 'log' ]
159- }
160- } ,
161- files : {
162- "build/separate-dompurify/<%= pkg.name %>.umd.min.js" : [ "build/separate-dompurify/<%= pkg.name %>.umd.js" ]
163- }
164- } ,
165- } ,
16610 cssmin : {
16711 min : {
16812 src : [ "styles/ableplayer.css" ] ,
@@ -175,17 +19,6 @@ module.exports = function (grunt) {
17519 banner : "/*! <%= pkg.name %> V<%= pkg.version %> */" ,
17620 } ,
17721 } ,
178- jshint : {
179- files : [ "Gruntfile.js" , "scripts/**/*.js" ] ,
180- options : {
181- // options here to override JSHint defaults
182- globals : {
183- browser : true ,
184- jquery : true ,
185- devel : true ,
186- } ,
187- } ,
188- } ,
18922 run : {
19023 rollup : {
19124 cmd : 'npm' ,
@@ -196,27 +29,18 @@ module.exports = function (grunt) {
19629 args : [ 'exec' , 'jest' , '--' , '--colors' ]
19730 }
19831 } ,
32+ eslint : {
33+ target : [ 'scripts/*.js' ] ,
34+ } ,
19935 clean : {
20036 build : [ "build" ] ,
20137 } ,
20238 } ) ;
20339
20440 grunt . registerTask ( "default" , [
205- "concat:build" ,
206- "removelogging:dist" ,
207- "decomment" ,
208- "terser:min" ,
209- "cssmin" ,
210- ] ) ;
211- grunt . registerTask ( "build_separate_dompurify" , [
212- "concat:build_separate_dompurify" ,
213- "removelogging:dist_separate_dompurify" ,
214- "terser:min_separate_dompurify" ,
215- ] ) ;
216- grunt . registerTask ( "test" , [ "jshint" ] ) ;
217- grunt . registerTask ( "jest" , [ "run:rollup" , "run:jest" ] ) ;
218- grunt . registerTask ( "umd" , [
21941 "run:rollup" ,
22042 "cssmin" ,
22143 ] ) ;
44+ grunt . registerTask ( "test" , [ "eslint" ] ) ;
45+ grunt . registerTask ( "jest" , [ "run:rollup" , "run:jest" ] ) ;
22246} ;
0 commit comments