Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yuexiaoliang/vite-plugin-importmap
vite-plugin-importmap
https://github.com/yuexiaoliang/vite-plugin-importmap
Last synced: about 1 month ago
JSON representation
vite-plugin-importmap
- Host: GitHub
- URL: https://github.com/yuexiaoliang/vite-plugin-importmap
- Owner: yuexiaoliang
- License: mit
- Created: 2023-02-22T02:38:55.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-02-28T01:24:57.000Z (about 1 year ago)
- Last Synced: 2024-03-26T13:42:59.790Z (about 2 months ago)
- Language: TypeScript
- Size: 52.7 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-vite - vite-plugin-importmap - I call this SASS at the code level. (Plugins / Framework-agnostic Plugins)
README
# vite-plugin-importmap
I call this SASS at the code level.
## Usage
```js
import importmap from 'vite-plugin-importmap'const mark = process.env.VITE_OPEN_TYPE
export default defineConfig({
plugins: [importmap(mark)]
})
```## Examples
[More](examples)
vite.config.js
```js
import importmap from 'vite-plugin-importmap'const mark = 'v1'
export default defineConfig({
plugins: [importmap(mark)]
})```
### String
``` text
src
├─ main.js
├─ test.js
├─ test.v1.js
└─ test.v2.js
`````` js
import test from 'test.js' // test.v1.js
```### Array
``` text
src
├─ main.js
├─ test.js
└─ test[v1,v2].js
`````` js
import test from 'test.js' // test[v1,v2].js
```### JSON
``` text
├─ 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
``` json
{
"cat.jpg": {
"cat.other.jpg": ["v1", "v2"],
"cat.v3.jpg": ["v3"]
}
}
`````` js
import imgUrl from '../assets/cat.jpg' // ../assets/cat.other.jpg
```src/import.config.json
``` json
{
"test.js": {
"test.other.js": ["v1", "v2"],
"test.v3.js": ["v3"]
}
}
`````` js
import test from './test' // ./test.other.js
```## License
[License MIT](LICENSE)