Przeglądaj źródła

fix(create): Use actual server port for vite config

Michael Bromley 4 tygodni temu
rodzic
commit
60b9144165

+ 2 - 3
packages/create/src/create-vendure-app.ts

@@ -165,6 +165,7 @@ export async function createVendureApp(
         dockerfileSource,
         dockerComposeSource,
         tsconfigDashboardSource,
+        viteConfigSource,
         populateProducts,
         includeStorefront,
     } =
@@ -369,9 +370,7 @@ export async function createVendureApp(
             .then(() =>
                 fs.writeFile(path.join(serverRoot, 'tsconfig.dashboard.json'), tsconfigDashboardSource),
             )
-            .then(() =>
-                fs.copyFile(assetPath('vite.config.template.mts'), path.join(serverRoot, 'vite.config.mts')),
-            )
+            .then(() => fs.writeFile(path.join(serverRoot, 'vite.config.mts'), viteConfigSource))
             .then(() => createDirectoryStructure(serverRoot))
             .then(() => copyEmailTemplates(serverRoot));
     } catch (e: any) {

+ 1 - 0
packages/create/src/gather-user-responses.ts

@@ -317,6 +317,7 @@ async function generateSources(
         dockerfileSource: await createSourceFile('Dockerfile.hbs'),
         dockerComposeSource: await createSourceFile('docker-compose.hbs'),
         tsconfigDashboardSource: await createSourceFile('tsconfig.dashboard.hbs'),
+        viteConfigSource: await createSourceFile('vite.config.hbs'),
     };
 }
 

+ 1 - 0
packages/create/src/types.ts

@@ -10,6 +10,7 @@ export interface FileSources {
     dockerfileSource: string;
     dockerComposeSource: string;
     tsconfigDashboardSource: string;
+    viteConfigSource: string;
 }
 
 export interface UserResponses extends FileSources {

+ 1 - 1
packages/create/templates/vite.config.template.mts → packages/create/templates/vite.config.hbs

@@ -16,7 +16,7 @@ export default defineConfig({
             // and custom fields that are configured.
             vendureConfigPath: pathToFileURL('./src/vendure-config.ts'),
             // Points to the location of your Vendure server.
-            api: { host: 'http://localhost', port: 3000 },
+            api: { host: 'http://localhost', port: {{ port }} },
             // When you start the Vite server, your Admin API schema will
             // be introspected and the types will be generated in this location.
             // These types can be used in your dashboard extensions to provide