diff --git a/playground/iconfont.config.ts b/playground/iconfont.config.ts
index 4695319..d73734b 100644
--- a/playground/iconfont.config.ts
+++ b/playground/iconfont.config.ts
@@ -4,7 +4,7 @@ export default defineConfig([
{
url: '//at.alicdn.com/t/c/font_3998853_ms3o2yu816s.js',
fileName: 'iconfont-common.js',
- prefix: 'iconfont-',
+ prefix: 'iconfont',
iconJson: true,
iconifyJson: true,
},
diff --git a/playground/iconfont.json b/playground/iconfont.json
index 0248b7b..3001a7f 100644
--- a/playground/iconfont.json
+++ b/playground/iconfont.json
@@ -1 +1 @@
-{"prefix":"iconfont-","icons":{"switch":{"body":"","width":1024,"height":1024},"decrease":{"body":"","width":1024,"height":1024},"editor":{"body":"","width":1024,"height":1024},"complete":{"body":"","width":1024,"height":1024},"jurisdiction":{"body":"","width":1024,"height":1024},"publichousing":{"body":"","width":1024,"height":1024},"carryforward":{"body":"","width":1024,"height":1024},"icon_attention":{"body":"","width":1024,"height":1024},"withdraw":{"body":"","width":1024,"height":1024},"icon_facility":{"body":"","width":1024,"height":1024},"icon_elevator":{"body":"","width":1024,"height":1024},"icon_ground":{"body":"","width":1024,"height":1024},"icon_land":{"body":"","width":1024,"height":1024},"icon_photovoltaic":{"body":"","width":1024,"height":1024},"icon_car":{"body":"","width":1024,"height":1024},"icon_nursery":{"body":"","width":1024,"height":1024},"icon_project":{"body":"","width":1024,"height":1024},"list":{"body":"","width":1024,"height":1024},"apartment":{"body":"","width":1024,"height":1024},"underground":{"body":"","width":1024,"height":1024},"ground":{"body":"","width":1024,"height":1024},"cloose3":{"body":"","width":1024,"height":1024},"export":{"body":"","width":1024,"height":1024},"channel":{"body":"","width":1024,"height":1024},"flag":{"body":"","width":1024,"height":1024},"milestone":{"body":"","width":1024,"height":1024},"qualification":{"body":"","width":1024,"height":1024},"query":{"body":"","width":1024,"height":1024},"icon_phone":{"body":"","width":1024,"height":1024},"update":{"body":"","width":1024,"height":1024},"align-justify":{"body":"","width":1024,"height":1024},"align-right":{"body":"","width":1024,"height":1024},"assign":{"body":"","width":1024,"height":1024},"closed":{"body":"","width":1024,"height":1024},"contact":{"body":"","width":1024,"height":1024},"back":{"body":"","width":1024,"height":1024},"increase":{"body":"","width":1024,"height":1024},"font-color":{"body":"","width":1024,"height":1024},"on":{"body":"","width":1024,"height":1024},"indent-increase":{"body":"","width":1024,"height":1024},"garbage":{"body":"","width":1024,"height":1024},"format-clear":{"body":"","width":1024,"height":1024},"punctuation":{"body":"","width":1024,"height":1024},"location":{"body":"","width":1024,"height":1024},"search3":{"body":"","width":1024,"height":1024},"attachment2":{"body":"","width":1024,"height":1024},"font-bg":{"body":"","width":1024,"height":1024},"clue":{"body":"","width":1024,"height":1024},"correlation":{"body":"","width":1024,"height":1024},"bulk-edit":{"body":"","width":1024,"height":1024},"cutoff":{"body":"","width":1024,"height":1024},"date":{"body":"","width":1024,"height":1024},"double-quotes-r":{"body":"","width":1024,"height":1024},"people":{"body":"","width":1024,"height":1024},"e-mail":{"body":"","width":1024,"height":1024},"font-size 2":{"body":"","width":1024,"height":1024},"H":{"body":"","width":1024,"height":1024},"record":{"body":"","width":1024,"height":1024},"start":{"body":"","width":1024,"height":1024},"narrow":{"body":"","width":1024,"height":1024},"full":{"body":"","width":1024,"height":1024},"save":{"body":"","width":1024,"height":1024},"pause":{"body":"","width":1024,"height":1024},"down":{"body":"","width":1024,"height":1024},"tick":{"body":"","width":1024,"height":1024},"line-height":{"body":"","width":1024,"height":1024},"punctuation 2":{"body":"","width":1024,"height":1024},"search":{"body":"","width":1024,"height":1024},"pic":{"body":"","width":1024,"height":1024},"space":{"body":"","width":1024,"height":1024},"up":{"body":"","width":1024,"height":1024},"video":{"body":"","width":1024,"height":1024},"tilt":{"body":"","width":1024,"height":1024},"more":{"body":"","width":1024,"height":1024},"small":{"body":"","width":1024,"height":1024},"phone":{"body":"","width":1024,"height":1024},"indent-decrease":{"body":"","width":1024,"height":1024},"merge":{"body":"","width":1024,"height":1024},"up2":{"body":"","width":1024,"height":1024},"time":{"body":"","width":1024,"height":1024},"left":{"body":"","width":1024,"height":1024},"number":{"body":"","width":1024,"height":1024},"right":{"body":"","width":1024,"height":1024},"underline":{"body":"","width":1024,"height":1024},"strikethrough":{"body":"","width":1024,"height":1024},"problem":{"body":"","width":1024,"height":1024},"view":{"body":"","width":1024,"height":1024},"set":{"body":"","width":1024,"height":1024},"often":{"body":"","width":1024,"height":1024},"send":{"body":"","width":1024,"height":1024},"project":{"body":"","width":1024,"height":1024},"align-justify 2":{"body":"","width":1024,"height":1024},"bold":{"body":"","width":1024,"height":1024},"code-view":{"body":"","width":1024,"height":1024},"align-left":{"body":"","width":1024,"height":1024},"building":{"body":"","width":1024,"height":1024},"attachment 2":{"body":"","width":1024,"height":1024},"align-center":{"body":"","width":1024,"height":1024},"copy":{"body":"","width":1024,"height":1024},"delete":{"body":"","width":1024,"height":1024},"close-eyes":{"body":"","width":1024,"height":1024},"cancel":{"body":"","width":1024,"height":1024},"arrow":{"body":"","width":1024,"height":1024},"attachment":{"body":"","width":1024,"height":1024},"cloose2":{"body":"","width":1024,"height":1024},"font-size":{"body":"","width":1024,"height":1024},"attachment_document":{"body":"","width":1024,"height":1024},"attachment_compress":{"body":"","width":1024,"height":1024},"attachment_mp4":{"body":"","width":1024,"height":1024},"attachment_jpeg":{"body":"","width":1024,"height":1024},"attachment_jpg":{"body":"","width":1024,"height":1024},"attachment_pdf":{"body":"","width":1024,"height":1024},"attachment_txt":{"body":"","width":1024,"height":1024},"attachment_other":{"body":"","width":1024,"height":1024},"attachment_docx":{"body":"","width":1024,"height":1024},"attachment_png":{"body":"","width":1024,"height":1024},"attachment_xlsx":{"body":"","width":1024,"height":1024}}}
\ No newline at end of file
+{"prefix":"iconfont","icons":{"switch":{"body":"","width":1024,"height":1024},"decrease":{"body":"","width":1024,"height":1024},"editor":{"body":"","width":1024,"height":1024},"complete":{"body":"","width":1024,"height":1024},"jurisdiction":{"body":"","width":1024,"height":1024},"publichousing":{"body":"","width":1024,"height":1024},"carryforward":{"body":"","width":1024,"height":1024},"icon_attention":{"body":"","width":1024,"height":1024},"withdraw":{"body":"","width":1024,"height":1024},"icon_facility":{"body":"","width":1024,"height":1024},"icon_elevator":{"body":"","width":1024,"height":1024},"icon_ground":{"body":"","width":1024,"height":1024},"icon_land":{"body":"","width":1024,"height":1024},"icon_photovoltaic":{"body":"","width":1024,"height":1024},"icon_car":{"body":"","width":1024,"height":1024},"icon_nursery":{"body":"","width":1024,"height":1024},"icon_project":{"body":"","width":1024,"height":1024},"list":{"body":"","width":1024,"height":1024},"apartment":{"body":"","width":1024,"height":1024},"underground":{"body":"","width":1024,"height":1024},"ground":{"body":"","width":1024,"height":1024},"cloose3":{"body":"","width":1024,"height":1024},"export":{"body":"","width":1024,"height":1024},"channel":{"body":"","width":1024,"height":1024},"flag":{"body":"","width":1024,"height":1024},"milestone":{"body":"","width":1024,"height":1024},"qualification":{"body":"","width":1024,"height":1024},"query":{"body":"","width":1024,"height":1024},"icon_phone":{"body":"","width":1024,"height":1024},"update":{"body":"","width":1024,"height":1024},"align-justify":{"body":"","width":1024,"height":1024},"align-right":{"body":"","width":1024,"height":1024},"assign":{"body":"","width":1024,"height":1024},"closed":{"body":"","width":1024,"height":1024},"contact":{"body":"","width":1024,"height":1024},"back":{"body":"","width":1024,"height":1024},"increase":{"body":"","width":1024,"height":1024},"font-color":{"body":"","width":1024,"height":1024},"on":{"body":"","width":1024,"height":1024},"indent-increase":{"body":"","width":1024,"height":1024},"garbage":{"body":"","width":1024,"height":1024},"format-clear":{"body":"","width":1024,"height":1024},"punctuation":{"body":"","width":1024,"height":1024},"location":{"body":"","width":1024,"height":1024},"search3":{"body":"","width":1024,"height":1024},"attachment2":{"body":"","width":1024,"height":1024},"font-bg":{"body":"","width":1024,"height":1024},"clue":{"body":"","width":1024,"height":1024},"correlation":{"body":"","width":1024,"height":1024},"bulk-edit":{"body":"","width":1024,"height":1024},"cutoff":{"body":"","width":1024,"height":1024},"date":{"body":"","width":1024,"height":1024},"double-quotes-r":{"body":"","width":1024,"height":1024},"people":{"body":"","width":1024,"height":1024},"e-mail":{"body":"","width":1024,"height":1024},"font-size 2":{"body":"","width":1024,"height":1024},"H":{"body":"","width":1024,"height":1024},"record":{"body":"","width":1024,"height":1024},"start":{"body":"","width":1024,"height":1024},"narrow":{"body":"","width":1024,"height":1024},"full":{"body":"","width":1024,"height":1024},"save":{"body":"","width":1024,"height":1024},"pause":{"body":"","width":1024,"height":1024},"down":{"body":"","width":1024,"height":1024},"tick":{"body":"","width":1024,"height":1024},"line-height":{"body":"","width":1024,"height":1024},"punctuation 2":{"body":"","width":1024,"height":1024},"search":{"body":"","width":1024,"height":1024},"pic":{"body":"","width":1024,"height":1024},"space":{"body":"","width":1024,"height":1024},"up":{"body":"","width":1024,"height":1024},"video":{"body":"","width":1024,"height":1024},"tilt":{"body":"","width":1024,"height":1024},"more":{"body":"","width":1024,"height":1024},"small":{"body":"","width":1024,"height":1024},"phone":{"body":"","width":1024,"height":1024},"indent-decrease":{"body":"","width":1024,"height":1024},"merge":{"body":"","width":1024,"height":1024},"up2":{"body":"","width":1024,"height":1024},"time":{"body":"","width":1024,"height":1024},"left":{"body":"","width":1024,"height":1024},"number":{"body":"","width":1024,"height":1024},"right":{"body":"","width":1024,"height":1024},"underline":{"body":"","width":1024,"height":1024},"strikethrough":{"body":"","width":1024,"height":1024},"problem":{"body":"","width":1024,"height":1024},"view":{"body":"","width":1024,"height":1024},"set":{"body":"","width":1024,"height":1024},"often":{"body":"","width":1024,"height":1024},"send":{"body":"","width":1024,"height":1024},"project":{"body":"","width":1024,"height":1024},"align-justify 2":{"body":"","width":1024,"height":1024},"bold":{"body":"","width":1024,"height":1024},"code-view":{"body":"","width":1024,"height":1024},"align-left":{"body":"","width":1024,"height":1024},"building":{"body":"","width":1024,"height":1024},"attachment 2":{"body":"","width":1024,"height":1024},"align-center":{"body":"","width":1024,"height":1024},"copy":{"body":"","width":1024,"height":1024},"delete":{"body":"","width":1024,"height":1024},"close-eyes":{"body":"","width":1024,"height":1024},"cancel":{"body":"","width":1024,"height":1024},"arrow":{"body":"","width":1024,"height":1024},"attachment":{"body":"","width":1024,"height":1024},"cloose2":{"body":"","width":1024,"height":1024},"font-size":{"body":"","width":1024,"height":1024},"attachment_document":{"body":"","width":1024,"height":1024},"attachment_compress":{"body":"","width":1024,"height":1024},"attachment_mp4":{"body":"","width":1024,"height":1024},"attachment_jpeg":{"body":"","width":1024,"height":1024},"attachment_jpg":{"body":"","width":1024,"height":1024},"attachment_pdf":{"body":"","width":1024,"height":1024},"attachment_txt":{"body":"","width":1024,"height":1024},"attachment_other":{"body":"","width":1024,"height":1024},"attachment_docx":{"body":"","width":1024,"height":1024},"attachment_png":{"body":"","width":1024,"height":1024},"attachment_xlsx":{"body":"","width":1024,"height":1024}}}
\ No newline at end of file
diff --git a/playground/vite.config.ts b/playground/vite.config.ts
index 6abfbe6..614702f 100644
--- a/playground/vite.config.ts
+++ b/playground/vite.config.ts
@@ -5,6 +5,6 @@ import Unplugin from '../src/vite'
export default defineConfig({
plugins: [
Inspect(),
- Unplugin(),
+ Unplugin({ configFile: './iconfont.config.ts' }),
],
})
diff --git a/src/index.ts b/src/index.ts
index 422d7db..7e13c40 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -10,12 +10,6 @@ let frameConfig: any
export const unpluginFactory: UnpluginFactory = options => ({
name: 'unplugin-iconfont',
- transformInclude(id) {
- return (
- id.endsWith('iconfont.config.', id.length - 2)
- || id.endsWith('iconfont.config.', id.length - 3)
- )
- },
async transform() {
let config = Array.isArray(options) ? options : options ? [options] : [] as any[]
config = (await loadConfig({
@@ -30,10 +24,10 @@ export const unpluginFactory: UnpluginFactory = options =>
],
defaults: config,
})).config
- if (!config.length || !config.every(c => c.url))
+ if (!config.length || !config.every(c => c.url || c.configFile))
this.error(`Options url parameter is required`)
- config = config.map((c) => {
+ config = config.filter(c => c.url).map((c) => {
const urlArr = c.url.split(/\//g)
return Object.assign(
{
@@ -66,7 +60,7 @@ export const unpluginFactory: UnpluginFactory = options =>
if (c.prefix) {
URL_CONTENT = URL_CONTENT.replace(
/