Vite Plugin DLight Server
raw JSON → 0.9.21 verified Fri May 01 auth: no javascript
Vite plugin that transpiles DLight.js JSX-like syntax for server-side rendering, enabling DLight components to be used in Vite-based projects. Current stable version is 0.9.21, with weekly releases. Integrates seamlessly with Vite's build pipeline, handling DLight template compilation and HMR. Key differentiator: provides server-side rendering support for DLight, complementing the client-side @dl-light/dlight plugin.
Common errors
error Error: The plugin 'vite-plugin-dlight-server' requires Vite 4 or higher. ↓
cause Project uses Vite 3 which is incompatible with plugin version 0.9.0+.
fix
Upgrade Vite: npm install vite@latest
error TypeError: vitePluginDLightServer is not a function ↓
cause Importing the plugin incorrectly due to ESM/CJS mismatch.
fix
Use ES6 import: import vitePluginDLightServer from 'vite-plugin-dlight-server'
error Error: Cannot find module '@dl-light/dlight' ↓
cause Missing dependency @dl-light/dlight which is required at runtime.
fix
Install the package: npm install @dl-light/dlight
Warnings
breaking Requires Vite 4+; incompatible with Vite 3.x. ↓
fix Upgrade to Vite 4 or 5.
breaking Dropped support for Node.js 14; now requires Node 16+. ↓
fix Update to Node 16 or higher.
gotcha The plugin must be placed before @dl-light/dlight in the plugins array. ↓
fix Reorder plugins: vitePluginDLightServer() first, then dlight().
deprecated The 'server' option is deprecated; use 'ssr' option instead. ↓
fix Replace server: true with ssr: true in plugin options.
Install
npm install vite-plugin-dlight-server yarn add vite-plugin-dlight-server pnpm add vite-plugin-dlight-server Imports
- default (plugin function) wrong
const vitePluginDLightServer = require('vite-plugin-dlight-server')correctimport vitePluginDLightServer from 'vite-plugin-dlight-server' - vitePluginDLightServer (named export) wrong
import VitePluginDLightServer from 'vite-plugin-dlight-server'correctimport { vitePluginDLightServer } from 'vite-plugin-dlight-server' - VitePluginConfig (type)
import type { VitePluginConfig } from 'vite-plugin-dlight-server'
Quickstart
import { defineConfig } from 'vite';
import vitePluginDLightServer from 'vite-plugin-dlight-server';
import dlight from '@dl-light/dlight';
export default defineConfig({
plugins: [
vitePluginDLightServer(),
dlight()
]
});