Skip to content

Commit

Permalink
fix: inject instead of auto import server entry
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Aug 23, 2024
1 parent 3340f62 commit 4784186
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/vike-node/src/plugin/plugins/serverEntryPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pc from '@brillout/picocolors'
import { createRequire } from 'module'
import path from 'path'
import type { Plugin } from 'vite'
import type { Plugin, ResolvedConfig } from 'vite'
import type { EntryResolved } from '../../types.js'
import { assert, assertUsage } from '../../utils/assert.js'
import { getConfigVikeNode } from '../utils/getConfigVikeNode.js'
Expand All @@ -10,10 +10,17 @@ import { viteIsSSR } from '../utils/viteIsSSR.js'

const require_ = createRequire(import.meta.url)

type ConfigVitePluginServerEntry = {
vitePluginServerEntry?: {
autoImport?: boolean
inject?: boolean | string[]
}
}

export function serverEntryPlugin(): Plugin {
return {
name: 'vike-node:serverEntry',
async configResolved(config) {
async configResolved(config: ResolvedConfig & ConfigVitePluginServerEntry) {
const resolvedConfig = getConfigVikeNode(config)
const { entry } = resolvedConfig.server
const entries = Object.entries(entry)
Expand Down Expand Up @@ -48,6 +55,9 @@ export function serverEntryPlugin(): Plugin {
config
)
}

config.vitePluginServerEntry ??= {}
config.vitePluginServerEntry.inject = Object.keys(resolvedEntries)
}
}
}

0 comments on commit 4784186

Please sign in to comment.