Skip to main content

Using Eik with Vite

This guide describes how to configure Vite to use build-time import mapping. The guide assumes you have an eik.json containing at least one "import-map".

Getting started

Install @eik/vite-plugin, and vite if you haven't already.

npm install --save-dev vite @eik/vite-plugin

Configure your build

Create or edit vite.config.ts to add the Eik plugin.

import eik from "@eik/vite-plugin";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [eik()],
});

Run your build

Add these scripts to package.json if you haven't already.

{
"scripts": {
"dev": "vite",
"build": "vite build"
}
}

Now you can run a production build using the Eik plugin by running this command.

npm run build

Advanced usage

See the plugin documentation for advanced options on loading import maps.