-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 优化转换配置、逻辑; 适配 vscode 插件; 适配 unocss ; (#15)
- Loading branch information
Showing
11 changed files
with
467 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,107 @@ | ||
# unplugin-iconify | ||
|
||
[![NPM version](https://img.shields.io/npm/v/unplugin-iconify?color=a1b858&label=)](https://www.npmjs.com/package/unplugin-iconify) | ||
|
||
Iconify template for [unplugin](https://github.com/unjs/unplugin). | ||
[![NPM version](https://img.shields.io/npm/v/@waset/unplugin-iconify?color=blue)](https://www.npmjs.com/package/@waset/unplugin-iconify) | ||
|
||
## Install | ||
|
||
```bash | ||
npm i -D unplugin-iconify | ||
pnpm i -D @waset/unplugin-iconify | ||
``` | ||
|
||
## Configuration | ||
|
||
```ts | ||
Iconify({ | ||
convert: { | ||
icon: './icons', | ||
svg: { | ||
path: './icons', | ||
noColor: true, | ||
}, | ||
suffix: { | ||
path: './icons', | ||
noColor: true, | ||
suffix: 'color', | ||
}, | ||
}, | ||
output: 'dist/icons', // @default 'node_modules/.unplugin-iconify' | ||
iconifyIntelliSense: true, // @default false | ||
}) | ||
``` | ||
|
||
- 如果开启 `iconifyIntelliSense`,将自动创建/更新 `.vscode/settings.json` 文件,用于 VSCode 插件 [Iconify IntelliSense](https://marketplace.visualstudio.com/items?itemName=antfu.iconify) | ||
|
||
- `convert` 选项用于将图标转换为图标集,请查看 `src/core/types.ts` 获取更多类型信息。 | ||
|
||
## Usage | ||
|
||
<details> | ||
<summary>Vite</summary> | ||
|
||
```ts | ||
// vite.config.ts | ||
import Iconify from '@waset/unplugin-iconify/vite' | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
Iconify({ | ||
// ... | ||
}) | ||
], | ||
}) | ||
``` | ||
</details> | ||
|
||
<details> | ||
<summary>Nuxt</summary> | ||
|
||
```ts | ||
// nuxt.config.ts | ||
import { defineNuxtConfig } from 'nuxt/config' | ||
|
||
// https://nuxt.com/docs/api/configuration/nuxt-config | ||
export default defineNuxtConfig({ | ||
modules: [ | ||
// ... | ||
'@waset/unplugin-iconify/nuxt' | ||
], | ||
Iconify: { | ||
// ... | ||
}, | ||
}) | ||
``` | ||
</details> | ||
|
||
<details> | ||
<summary>unocss</summary> | ||
|
||
```ts | ||
// uno.config.ts | ||
import { UnocssLoader } from '@waset/unplugin-iconify/loader' | ||
import { defineConfig, presetIcons } from 'unocss' | ||
|
||
export default defineConfig({ | ||
presets: [ | ||
// ... | ||
presetIcons({ | ||
scale: 1.2, | ||
warn: true, | ||
extraProperties: { | ||
'display': 'inline-block', | ||
'vertical-align': 'middle', | ||
}, | ||
collections: { | ||
...UnocssLoader(), | ||
}, | ||
}), | ||
], | ||
// ... | ||
}) | ||
``` | ||
</details> | ||
|
||
## Thanks | ||
|
||
- [unplugin](https://github.com/unjs/unplugin) | ||
- [unplugin/unplugin-icons](https://github.com/unplugin/unplugin-icons) | ||
- [unocss](https://github.com/unocss/unocss) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,6 @@ | |
"description": "", | ||
"author": "waset <[email protected]>", | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"homepage": "https://github.com/waset/unplugin-iconify#readme", | ||
"repository": { | ||
"type": "git", | ||
|
@@ -129,6 +126,7 @@ | |
} | ||
}, | ||
"dependencies": { | ||
"jsonc-parser": "^3.3.1", | ||
"unplugin": "^1.14.1" | ||
}, | ||
"devDependencies": { | ||
|
@@ -150,5 +148,8 @@ | |
"vitest": "^2.1.3", | ||
"webpack": "^5.95.0" | ||
}, | ||
"pubilc": true | ||
"pubilc": true, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,19 @@ | ||
import { defineConfig } from 'vite' | ||
import Inspect from 'vite-plugin-inspect' | ||
/** | ||
* package.json | ||
* | ||
* "unplugin-iconify": "workspaces:*", | ||
*/ | ||
// import Iconify from '../src/vite' | ||
import Iconify from '@waset/unplugin-iconify/vite' | ||
import Iconify from '../src/vite' | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
Inspect(), | ||
Iconify({ | ||
convert: [ | ||
{ | ||
convert: { | ||
svg: { | ||
path: './icons', | ||
prefix: 'icon', | ||
noColor: true, | ||
}, | ||
{ | ||
path: './icons', | ||
prefix: 'icon-color', | ||
}, | ||
], | ||
}) as any, | ||
icon: './icons', | ||
}, | ||
iconifyIntelliSense: true, | ||
}), | ||
], | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.