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

0.1.1 • Public • Published

vite-plugin-importmap

I call this SASS at the code level.

Usage

import importmap from 'vite-plugin-importmap'

const mark = process.env.VITE_OPEN_TYPE

export default defineConfig({
  plugins: [importmap(mark)]
})

Examples

More

vite.config.js

import importmap from 'vite-plugin-importmap'

const mark = 'v1'

export default defineConfig({
  plugins: [importmap(mark)]
})

String

src
├─ main.js
├─ test.js
├─ test.v1.js
└─ test.v2.js
import test from 'test.js' // test.v1.js

Array

src
├─ main.js
├─ test.js
└─ test[v1,v2].js
import test from 'test.js' // test[v1,v2].js

JSON

├─ assets
│  ├─ cat.jpg
│  ├─ cat.other.jpg
│  ├─ cat.v3.jpg
│  └─ import.config.json
├─ src
│  ├─ import.config.json
│  ├─ main.js
│  ├─ test.js
│  ├─ test.other.js
│  └─ test.v3.js
├─ index.html
├─ package.json
├─ pnpm-lock.yaml
└─ vite.config.js

assets/import.config.json

{
  "cat.jpg": {
    "cat.other.jpg": ["v1", "v2"],
    "cat.v3.jpg": ["v3"]
  }
}
import imgUrl from '../assets/cat.jpg' // ../assets/cat.other.jpg

src/import.config.json

{
  "test.js": {
    "test.other.js": ["v1", "v2"],
    "test.v3.js": ["v3"]
  }
}
import test from './test' // ./test.other.js

License

License MIT

Package Sidebar

Install

npm i vite-plugin-importmap

Weekly Downloads

1

Version

0.1.1

License

ISC

Unpacked Size

8.86 kB

Total Files

6

Last publish

Collaborators

  • yuexiaoliang1993