Explorar el Código

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

David Höck hace 10 meses
padre
commit
f3f094720f

+ 3 - 2
.vscode/settings.json

@@ -18,5 +18,6 @@
         "ui-devkit",
         "ui-devkit",
         "repo"
         "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.
  * Returns the path to the root of the `@vendure/dashboard` package.
  */
  */
 function getDashboardPackageRoot(): string {
 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 {
 function getNormalizedVendureConfigPath(vendureConfigPath: string | URL): string {
     const stringPath = typeof vendureConfigPath === 'string' ? vendureConfigPath : vendureConfigPath.href;
     const stringPath = typeof vendureConfigPath === 'string' ? vendureConfigPath : vendureConfigPath.href;
-    return stringPath.replace(/^file:[\//]+/, '/');
+    if (stringPath.startsWith('file:')) {
+        return new URL(stringPath).pathname;
+    }
+    return stringPath;
 }
 }