Skip to content

Commit 558add0

Browse files
committed
chore: remove preview plugin
1 parent ba2aeb4 commit 558add0

File tree

4 files changed

+8
-282
lines changed

4 files changed

+8
-282
lines changed

src/module.ts

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
addImports,
88
addComponentsDir,
99
addTemplate,
10-
addComponent
10+
extendViteConfig
1111
} from '@nuxt/kit'
1212
import { genImport, genSafeVariableName } from 'knitwork'
1313
import type { ListenOptions } from 'listhen'
@@ -247,16 +247,13 @@ export default defineNuxtModule<ModuleOptions>({
247247
}
248248

249249
// Add Vite configurations
250-
if (nuxt.options.vite !== false) {
251-
nuxt.options.vite = defu(
252-
nuxt.options.vite === true ? {} : nuxt.options.vite,
253-
{
254-
optimizeDeps: {
255-
include: ['html-tags']
256-
}
257-
}
250+
extendViteConfig((config) => {
251+
config.optimizeDeps = config.optimizeDeps || {}
252+
config.optimizeDeps.include = config.optimizeDeps.include || []
253+
config.optimizeDeps.include.push(
254+
'html-tags'
258255
)
259-
}
256+
})
260257

261258
// Add Content plugin
262259
addPlugin(resolveRuntimeModule('./plugins/ws'))
@@ -553,34 +550,6 @@ export default defineNuxtModule<ModuleOptions>({
553550
tailwindConfig.content.push(resolve(nuxt.options.buildDir, 'content-cache', 'parsed/**/*.md'))
554551
})
555552

556-
// Experimental preview mode
557-
if (process.env.NUXT_PREVIEW_API) {
558-
// Add preview plugin
559-
addPlugin(resolveRuntimeModule('./preview/preview-plugin'))
560-
561-
// Add preview components
562-
addComponent({
563-
name: 'ContentPreviewMode',
564-
filePath: resolveRuntimeModule('./preview/components/ContentPreviewMode.vue')
565-
})
566-
567-
// @ts-ignore
568-
nuxt.options.runtimeConfig.public.content.previewAPI = process.env.NUXT_PREVIEW_API
569-
// @ts-ignore
570-
nuxt.options.runtimeConfig.content.previewAPI = process.env.NUXT_PREVIEW_API
571-
572-
if (nuxt.options.vite !== false) {
573-
nuxt.options.vite = defu(
574-
nuxt.options.vite === true ? {} : nuxt.options.vite,
575-
{
576-
optimizeDeps: {
577-
include: ['socket.io-client', 'slugify']
578-
}
579-
}
580-
)
581-
}
582-
}
583-
584553
// Setup content dev module
585554
if (!nuxt.options.dev) {
586555
nuxt.hook('build:before', async () => {
@@ -684,8 +653,6 @@ interface ModulePrivateRuntimeConfig {
684653
*/
685654
cacheVersion: string;
686655
cacheIntegrity: string;
687-
688-
previewAPI?: string
689656
}
690657

691658
declare module '@nuxt/schema' {

src/runtime/composables/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ export const addPrerenderPath = (path: string) => {
4343
}
4444

4545
export const shouldUseClientDB = () => {
46-
const { previewAPI, clientDB } = useRuntimeConfig().content
46+
const { clientDB } = useRuntimeConfig().content
4747
if (!process.client) { return false }
4848
if (clientDB?.isSPA) { return true }
4949

5050
// Disable clientDB when preview mode is disabled
51-
if (!previewAPI) { return false }
5251
if (useRoute().query?.preview || useCookie('previewToken').value) {
5352
return true
5453
}

src/runtime/preview/components/ContentPreviewMode.vue

Lines changed: 0 additions & 162 deletions
This file was deleted.

src/runtime/preview/preview-plugin.ts

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)