Supporting importmap for local development
When adding your import map. Plese follow this convention in this order.
data-src-type="importmap"
src="/path/to/importmap.js"
<script
data-src-type="importmap"
src="/path/to/importmap.js"
>
</script>
<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script data-src-type="importmap" src="/js/importmap.js"></script>
</head>
<body>
<div id="root"></div>
<script src="/src/index.jsx" type="module"></script>
</body>
</html>
```
```
/** vite.config.js */
import { defineConfig } from "vite";
import { jsImportMapScriptPlugin } from "vite-plugin-js-importmap-script"
export default defineConfig(async (options) => {
if (options.mode === "development") {
return {
server: {
hmr: true,
port: 3001,
host: "localhost",
},
plugins: [
jsImportMapScriptPlugin(),
],
}
}
});
```