Skip to content

vite下运行,__dirname 会报错 #3

@aoiu

Description

@aoiu

https://github.com/lishaobos/svg-preview-plugin/blob/c0bda8e8e42fc288b8c06f41cf568db4dece5446/utils/index.ts#L1C1-L3C72

vite下运行__dirname 会报错,需要改成下面这样:

import path from "path";
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(new URL(import.meta.url));
const __dirname = path.dirname(__filename);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions