diff --git a/packages/vike-node/src/plugin/index.ts b/packages/vike-node/src/plugin/index.ts index ec3083f..a2ba709 100644 --- a/packages/vike-node/src/plugin/index.ts +++ b/packages/vike-node/src/plugin/index.ts @@ -1,7 +1,9 @@ export { vikeNode, vikeNode as default } +import pc from '@brillout/picocolors' import { globalStore } from '../runtime/globalStore.js' import type { ConfigVikeNodePlugin } from '../types.js' +import { assertUsage } from '../utils/assert.js' import { commonConfig } from './plugins/commonConfig.js' import { devServerPlugin } from './plugins/devServerPlugin.js' import { edgePlugin } from './plugins/edgePlugin.js' @@ -12,11 +14,19 @@ globalStore.isDev = true function vikeNode(config: ConfigVikeNodePlugin) { return [ - // commonConfig(config), serverEntryPlugin(), devServerPlugin(), standalonePlugin(), - edgePlugin() + edgePlugin(), + { + name: 'vike-node:forbid-vite-preview-command', + configurePreviewServer() { + assertUsage( + false, + `${pc.cyan('$ vite preview')} isn't supported: directly execute the server production entry (for example ${pc.cyan('$ node dist/server/index.mjs')}) instead.` + ) + } + } ] } diff --git a/packages/vike-node/src/utils/assert.ts b/packages/vike-node/src/utils/assert.ts index 3d74a2d..884698c 100644 --- a/packages/vike-node/src/utils/assert.ts +++ b/packages/vike-node/src/utils/assert.ts @@ -7,5 +7,5 @@ function assert(condition: unknown): asserts condition { function assertUsage(condition: unknown, message: string): asserts condition { if (condition) return - throw new Error(`[vike-node] wrong usage: ${message}`) + throw new Error(`[vike-node][Wrong Usage] ${message}`) }