Skip to content

Instantly share code, notes, and snippets.

@acip
Last active March 2, 2023 16:46
Show Gist options
  • Save acip/52bc1b588f31393333ddd77df779bd33 to your computer and use it in GitHub Desktop.
Save acip/52bc1b588f31393333ddd77df779bd33 to your computer and use it in GitHub Desktop.
JavaScript Import Maps - use Laravel mix for modules versioning
<script type="importmap">
{
"scopes": {
"/path/to/modules": {
"m1": "{{ mix("/js/m1.js") }}",
"m2": "{{ mix("/js/m2.js") }}"
}
}
}
</script>
{{--
Notes:
1. The structure should be a valid JSON (e.g. no trailing commas)
2. Relative paths for module name are not considered, so ./m1.js instead of m1 doesn't work.
--}}
@acip
Copy link
Author

acip commented Mar 2, 2023

At this moment, Safari doesn't support import maps for JavaScript. Use Import Maps polyfill.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment