Преглед на файлове

fix(dashboard): Improve file path resolution for dashboard package

David Höck преди 10 месеца
родител
ревизия
f3f094720f
променени са 2 файла, в които са добавени 10 реда и са изтрити 4 реда
  1. 3 2
      .vscode/settings.json
  2. 7 2
      packages/dashboard/vite/vite-plugin-vendure-dashboard.ts

+ 3 - 2
.vscode/settings.json

@@ -18,5 +18,6 @@
         "ui-devkit",
         "repo"
     ],
-    "conventionalCommits.gitmoji": false
-}
+    "conventionalCommits.gitmoji": false,
+    "typescript.tsdk": "node_modules/typescript/lib"
+}

+ 7 - 2
packages/dashboard/vite/vite-plugin-vendure-dashboard.ts

@@ -60,7 +60,9 @@ export function vendureDashboardPlugin(options: VitePluginVendureDashboardOption
  * Returns the path to the root of the `@vendure/dashboard` package.
  */
 function getDashboardPackageRoot(): string {
-    return path.join(import.meta.resolve('@vendure/dashboard'), '../..').replace(/^file:\/+/, '/');
+    const fileUrl = import.meta.resolve('@vendure/dashboard');
+    const packagePath = fileUrl.startsWith('file:') ? new URL(fileUrl).pathname : fileUrl;
+    return path.join(packagePath, '../..');
 }
 
 /**
@@ -68,5 +70,8 @@ function getDashboardPackageRoot(): string {
  */
 function getNormalizedVendureConfigPath(vendureConfigPath: string | URL): string {
     const stringPath = typeof vendureConfigPath === 'string' ? vendureConfigPath : vendureConfigPath.href;
-    return stringPath.replace(/^file:[\//]+/, '/');
+    if (stringPath.startsWith('file:')) {
+        return new URL(stringPath).pathname;
+    }
+    return stringPath;
 }