Skip to content

Commit

Permalink
chore: remove preview plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Oct 12, 2022
1 parent ba2aeb4 commit 558add0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 282 deletions.
47 changes: 7 additions & 40 deletions src/module.ts
Expand Up @@ -7,7 +7,7 @@ import {
addImports,
addComponentsDir,
addTemplate,
addComponent
extendViteConfig
} from '@nuxt/kit'
import { genImport, genSafeVariableName } from 'knitwork'
import type { ListenOptions } from 'listhen'
Expand Down Expand Up @@ -247,16 +247,13 @@ export default defineNuxtModule<ModuleOptions>({
}

// Add Vite configurations
if (nuxt.options.vite !== false) {
nuxt.options.vite = defu(
nuxt.options.vite === true ? {} : nuxt.options.vite,
{
optimizeDeps: {
include: ['html-tags']
}
}
extendViteConfig((config) => {
config.optimizeDeps = config.optimizeDeps || {}
config.optimizeDeps.include = config.optimizeDeps.include || []
config.optimizeDeps.include.push(
'html-tags'
)
}
})

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

// Experimental preview mode
if (process.env.NUXT_PREVIEW_API) {
// Add preview plugin
addPlugin(resolveRuntimeModule('./preview/preview-plugin'))

// Add preview components
addComponent({
name: 'ContentPreviewMode',
filePath: resolveRuntimeModule('./preview/components/ContentPreviewMode.vue')
})

// @ts-ignore
nuxt.options.runtimeConfig.public.content.previewAPI = process.env.NUXT_PREVIEW_API
// @ts-ignore
nuxt.options.runtimeConfig.content.previewAPI = process.env.NUXT_PREVIEW_API

if (nuxt.options.vite !== false) {
nuxt.options.vite = defu(
nuxt.options.vite === true ? {} : nuxt.options.vite,
{
optimizeDeps: {
include: ['socket.io-client', 'slugify']
}
}
)
}
}

// Setup content dev module
if (!nuxt.options.dev) {
nuxt.hook('build:before', async () => {
Expand Down Expand Up @@ -684,8 +653,6 @@ interface ModulePrivateRuntimeConfig {
*/
cacheVersion: string;
cacheIntegrity: string;

previewAPI?: string
}

declare module '@nuxt/schema' {
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/composables/utils.ts
Expand Up @@ -43,12 +43,11 @@ export const addPrerenderPath = (path: string) => {
}

export const shouldUseClientDB = () => {
const { previewAPI, clientDB } = useRuntimeConfig().content
const { clientDB } = useRuntimeConfig().content
if (!process.client) { return false }
if (clientDB?.isSPA) { return true }

// Disable clientDB when preview mode is disabled
if (!previewAPI) { return false }
if (useRoute().query?.preview || useCookie('previewToken').value) {
return true
}
Expand Down
162 changes: 0 additions & 162 deletions src/runtime/preview/components/ContentPreviewMode.vue

This file was deleted.

78 changes: 0 additions & 78 deletions src/runtime/preview/preview-plugin.ts

This file was deleted.

0 comments on commit 558add0

Please sign in to comment.