Add support for multiple asset types #485
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed with @grymmy and @karamassie, this is a nice-to-have for after launch, but not required for launch. This is related to #482
This adds support for smartly choosing the asset to import based on browser compatibility. It also includes an example, switching the import string
sounds.music.intro: '.mp3'to the arraysounds.music.intro: ['.m4a', '.mp3'].It's still backwards compatible with the previous import file, but now switching imports to an array like that will to through them first to last, check if the file is compatible with the current browser (using howler.js, so we don't have to maintain it) and import the first file that works. It can even be extended to something like
sounds.music.intro: ['.webm', '.ogg', '.m4a', '.mp3']as long as all 4 files are in the assets folder. In this example, we go from most efficient compression (but less supported) formats (.webm) sliding to large filesize but compatible with any browser formats (.mp3).