Skip to content

Commit

Permalink
fix: add file protocol to solve windows pre rendering issues (#915)
Browse files Browse the repository at this point in the history
Co-authored-by: angelfraga <angelfraga@users.noreply.github.com>
  • Loading branch information
angelfraga and angelfraga committed Mar 1, 2024
1 parent 4aa6f9c commit cd1123f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/vite-plugin-nitro/src/lib/vite-plugin-nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { App, toNodeListener } from 'h3';
import type { Plugin, UserConfig } from 'vite';
import { normalizePath, ViteDevServer } from 'vite';
import * as path from 'path';
import { platform } from 'node:os';

import { buildServer } from './build-server';
import { buildSSRApp } from './build-ssr';
Expand All @@ -15,6 +16,7 @@ import { devServerPlugin } from './plugins/dev-server-plugin';
import { loadEsmModule } from './utils/load-esm';
import { getMatchingContentFilesWithFrontMatter } from './utils/get-content-files';

const isWindows = platform() === 'win32';
let clientOutputPath = '';

export function nitro(options?: Options, nitroOptions?: NitroConfig): Plugin[] {
Expand Down Expand Up @@ -104,9 +106,12 @@ export function nitro(options?: Options, nitroOptions?: NitroConfig): Plugin[] {
}

nitroConfig.alias = {
'#analog/ssr': normalizePath(
path.resolve(workspaceRoot, 'dist', rootDir, 'ssr/main.server')
),
// This is not the final fix but start point to discuss a fix for windows
'#analog/ssr':
(isWindows ? 'file://' : '') +
normalizePath(
path.resolve(workspaceRoot, 'dist', rootDir, 'ssr/main.server')
),
'#analog/index': normalizePath(
path.resolve(clientOutputPath, 'index.html')
),
Expand Down

0 comments on commit cd1123f

Please sign in to comment.