Skip to content

Commit

Permalink
feat: add support for Nx w/Project Crystal setup (#991)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts authored Apr 2, 2024
1 parent 5fb8a5e commit 2d7a581
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions packages/vite-plugin-nitro/src/lib/build-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ export async function buildSSRApp(config: UserConfig, options?: Options) {
build: {
ssr: true,
rollupOptions: {
input: options?.entryServer || resolve(rootDir, './src/main.server.ts'),
input:
options?.entryServer ||
resolve(workspaceRoot, rootDir, 'src/main.server.ts'),
},
outDir: options?.ssrBuildDir || resolve('dist', rootDir, 'ssr'),
outDir:
options?.ssrBuildDir || resolve(workspaceRoot, 'dist', rootDir, 'ssr'),
},
});

Expand Down
8 changes: 5 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 @@ -72,9 +72,6 @@ export function nitro(options?: Options, nitroOptions?: NitroConfig): Plugin[] {
`ssr/main.server${filePrefix ? '.js' : ''}`
)
);
const indexEntry = normalizePath(
resolve(clientOutputPath, 'index.html')
);
const rendererEntry =
filePrefix +
normalizePath(
Expand Down Expand Up @@ -130,11 +127,16 @@ export function nitro(options?: Options, nitroOptions?: NitroConfig): Plugin[] {
if (!ssrBuild && !isTest) {
// store the client output path for the SSR build config
clientOutputPath = resolve(
workspaceRoot,
rootDir,
config.build?.outDir || 'dist/client'
);
}

const indexEntry = normalizePath(
resolve(clientOutputPath, 'index.html')
);

nitroConfig.alias = {
'#analog/ssr': ssrEntry,
'#analog/index': indexEntry,
Expand Down

0 comments on commit 2d7a581

Please sign in to comment.