vite-plugin-js-importmap-script
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

vite-plugin-js-importmap-script

Supporting importmap for local development

Examples

IMPORTANT

When adding your import map. Plese follow this convention in this order.

  1. data-src-type="importmap"
  2. 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(),
        ],
    }
  }
});

```

Readme

Keywords

none

Package Sidebar

Install

npm i vite-plugin-js-importmap-script

Weekly Downloads

31

Version

1.0.0

License

ISC

Unpacked Size

9.42 kB

Total Files

10

Last publish

Collaborators

  • ferryrsvp