Skip to content

Commit 2a727a8

Browse files
authored
Merge pull request #67 from xuanhen2013/main
2 parents 1ffc2b7 + 66b2d7a commit 2a727a8

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

src/core/components.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import type { Options } from "../types";
2-
import { iconLibraryName, libraryName, prefix } from "../config"
2+
import { prefix } from "../config"
33
import { addComponent } from "@nuxt/kit";
44

5-
export const resolveComponents = (config:Options) =>{
5+
export const resolveComponents = (config:Options, filePath: string) =>{
6+
67
const { components,icons } = config;
78
const allComponents = components === false ? [] : components;
89
allComponents.forEach(component=>{
910
if (typeof component === 'string'){
1011
addComponent({
1112
export: component,
1213
name: prefix + component,
13-
filePath: libraryName + '/es'
14+
filePath
1415
})
1516
}else if (Array.isArray(component)){
1617
addComponent({
1718
export: component[0],
1819
name: prefix + component[1],
19-
filePath: libraryName + '/es'
20+
filePath
2021
})
2122
}
2223
})
@@ -29,13 +30,13 @@ export const resolveComponents = (config:Options) =>{
2930
addComponent({
3031
export: icon,
3132
name: icon,
32-
filePath: iconLibraryName
33+
filePath
3334
})
3435
}else if (Array.isArray(icon)){
3536
addComponent({
3637
export: icon[0],
3738
name: icon[1],
38-
filePath: iconLibraryName
39+
filePath
3940
})
4041
}
4142
})

src/core/imports.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { addImportsSources } from "@nuxt/kit";
22
import type { Options } from "../types";
3-
import { libraryName } from "../config";
43

5-
export const resolveImports = (config:Options) => {
4+
export const resolveImports = (config:Options, filePath: string) => {
65
const { imports } = config
76
const allImports = imports ? imports : []
87
addImportsSources({
9-
from: libraryName + '/es',
8+
from: filePath,
109
imports: [...allImports]
1110
})
1211
}

src/core/options.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ export function resolveOptions () {
1616
resolve:{
1717
alias:[
1818
{
19-
find: /^(ant-design-vue)(?!\/(es|dist))/,
19+
find: /^(ant-design-vue)(?!\/(es|lib))/,
2020
replacement: 'ant-design-vue/es',
2121
},
22+
{
23+
find: /^@ant-design\/icons-vue$/,
24+
replacement: '@ant-design/icons-vue',
25+
},
2226
{
2327
find: /^dayjs\/plugin\/(.*)$/,
2428
replacement: 'dayjs/esm/plugin/$1',

src/module.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ export default defineNuxtModule<Partial<Options>>({
1515
const options = _options as Options;
1616

1717
resolveOptions()
18+
19+
const antdRuntimePath = createResolver(import.meta.url).resolve('./runtime/antd')
20+
1821
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
19-
nuxt.options.imports.autoImport !== false && resolveImports(options)
22+
nuxt.options.imports.autoImport !== false && resolveImports(options, antdRuntimePath)
2023
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
21-
nuxt.options.components !== false && resolveComponents(options)
24+
nuxt.options.components !== false && resolveComponents(options, antdRuntimePath)
2225

2326
if (options.extractStyle) {
2427
extractStyle()

src/runtime/antd.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from 'ant-design-vue/es';
2+
export * from '@ant-design/icons-vue';

0 commit comments

Comments
 (0)