Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix viewer #658

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import type { Config } from 'tailwindcss'
// @ts-expect-error
import defaultTailwindConfig from 'tailwindcss/stubs/config.simple.js'
import { eventHandler, sendRedirect } from 'h3'
import { eventHandler, sendRedirect, H3Event } from 'h3'
import { name, version } from '../package.json'
import vitePlugin from './hmr'
import { createTemplates, InjectPosition, resolveInjectPosition } from './utils'
Expand Down Expand Up @@ -270,7 +270,7 @@ export default defineNuxtModule<ModuleOptions>({
})
if (isNuxt3()) { addDevServerHandler({ route, handler: viewerDevMiddleware }) }
// @ts-ignore
if (isNuxt2()) { nuxt.options.serverMiddleware.push({ route, handler: viewerDevMiddleware }) }
if (isNuxt2()) { nuxt.options.serverMiddleware.push({ route, handler: (req, res, next) => viewerDevMiddleware(new H3Event(req, res)) }) }
nuxt.hook('listen', (_, listener) => {
const viewerUrl = `${withoutTrailingSlash(listener.url)}${route}`
logger.info(`Tailwind Viewer: ${underline(yellow(withTrailingSlash(viewerUrl)))}`)
Expand Down