I use data URI, base64 to add images and videos to my games, but I found if I want to make a game with multiple videos it will be really bad code with more than 500 lines for each video, so is there any advice to treat this type of file, what I really do that I make a Mixin file and I make multiple functions that return base64.
export default{
stage1(){
return "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAFkAdtZGF0AAADAAYF///........."
},
stage2(){
return "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAFkAdtZGF0AAADAAYF///........."
},
}
I would recommend using a bundler like (webpack, parcel, rollup, browserify,...) you can programm in several files and before deployment the bundler will combine all files into an single file (and minifiy it).
Using a bundler like webpack you can create a json file with all dataurl's like:
in the app script:
and in the application file you can import teh json-file, and it will be integrated on the bundler build action. And create a single file with all files for the application.
For details on webpack and how to setup your project checkout the documentation. It is too long to describe it in an answer, and there are already good articles / video's out there. (but you can also use any other bundler)
I my answer points you in the right direction.
Update:
A small demo project (if you have node and npm installed):
Install with npm these packages
than create a basic config file for webpack:
here a demo app code:
The project structure for the demo would look like this:
And it would create just one output html-file, all other files are inlined.