Skip to content

Commit

Permalink
fix: 使用同构的 _dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
markthree committed Sep 11, 2023
1 parent 00440c9 commit f367d1a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions presets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ import Jsx from '@vitejs/plugin-vue-jsx'
import type { Plugin } from 'vite'
import type { ComponentResolver } from 'unplugin-vue-components/types'

export const _dirname =
typeof __dirname !== 'undefined'
? __dirname
: dirname(fileURLToPath(import.meta.url))

export default function () {
const env = useEnv()
const safelist =
Expand Down Expand Up @@ -122,7 +127,7 @@ export default function () {
directoryAsNamespace: true,
include: [/\.vue$/, /\.vue\?vue/, /\.[tj]sx$/, /\.md$/],
extensions: ['md', 'vue', 'tsx', 'jsx'],
dts: resolve(__dirname, './types/components.d.ts'),
dts: resolve(_dirname, './types/components.d.ts'),
types: [
{
from: 'vue-router',
Expand Down Expand Up @@ -310,11 +315,6 @@ export const normalizeResolvers = (options: Options = {}) => {
return existedResolvers
}

export const _dirname =
typeof __dirname !== 'undefined'
? __dirname
: dirname(fileURLToPath(import.meta.url))

/**
* 别名插件
* @description 支持 `~` 和 `@` 别名到 `src`
Expand Down

0 comments on commit f367d1a

Please sign in to comment.