Skip to content

Commit 97d72a4

Browse files
committed
chore: broken tests
1 parent e96c0d3 commit 97d72a4

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

src/assets.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { addDevServerHandler, useNuxt, tryUseNuxt } from '@nuxt/kit'
1+
import { addDevServerHandler, extendRouteRules, useNuxt, tryUseNuxt } from '@nuxt/kit'
22
import { createError, eventHandler, lazyEventHandler } from 'h3'
33
import { fetch } from 'ofetch'
4-
import { defu } from 'defu'
54
import type { NitroConfig } from 'nitropack'
65
import { joinURL } from 'ufo'
76
import { join, resolve } from 'pathe'
@@ -10,6 +9,12 @@ import fsDriver from 'unstorage/drivers/fs-lite'
109

1110
import type { ModuleOptions } from './module'
1211

12+
declare module '@nuxt/schema' {
13+
interface NuxtHooks {
14+
'nitro:config': (config: NitroConfig) => void | Promise<void>
15+
}
16+
}
17+
1318
const renderedScript = new Map<string, {
1419
content: Buffer
1520
/**
@@ -72,27 +77,25 @@ export function setupPublicAssetStrategy(options: ModuleOptions['assets'] = {})
7277
})
7378

7479
if (nuxt.options.dev) {
75-
nuxt.options.routeRules ||= {}
76-
nuxt.options.routeRules[joinURL(assetsBaseURL, '**')] = {
80+
extendRouteRules(joinURL(assetsBaseURL, '**'), {
7781
cache: {
7882
maxAge: ONE_YEAR_IN_SECONDS,
7983
},
80-
}
84+
})
8185
}
8286

83-
nuxt.options.nitro.publicAssets ||= []
8487
const cacheDir = join(nuxt.options.buildDir, 'cache', 'scripts')
85-
nuxt.options.nitro.publicAssets.push()
86-
nuxt.options.nitro = defu(nuxt.options.nitro, {
87-
publicAssets: [{
88+
nuxt.hook('nitro:config', (nitroConfig) => {
89+
nitroConfig.publicAssets ||= []
90+
nitroConfig.publicAssets.push({
8891
dir: cacheDir,
8992
maxAge: ONE_YEAR_IN_SECONDS,
9093
baseURL: assetsBaseURL,
91-
}],
92-
prerender: {
93-
ignore: [assetsBaseURL],
94-
},
95-
} satisfies NitroConfig)
94+
})
95+
nitroConfig.prerender ||= {}
96+
nitroConfig.prerender.ignore ||= []
97+
nitroConfig.prerender.ignore.push(assetsBaseURL)
98+
})
9699

97100
return {
98101
renderedScript,

src/devtools.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { existsSync } from 'node:fs'
22
import type { Nuxt } from '@nuxt/schema'
33
import type { Resolver } from '@nuxt/kit'
44
import { extendViteConfig, useNuxt } from '@nuxt/kit'
5+
import { addCustomTab } from '@nuxt/devtools-kit'
56
import type { ModuleOptions } from './module'
67
import { DEVTOOLS_UI_LOCAL_PORT, DEVTOOLS_UI_ROUTE } from './constants'
78

@@ -33,19 +34,17 @@ export async function setupDevToolsUI(options: ModuleOptions, resolve: Resolver[
3334
})
3435
}
3536

36-
nuxt.hook('devtools:customTabs', (tabs) => {
37-
tabs.push({
38-
// unique identifier
39-
name: 'nuxt-scripts',
40-
// title to display in the tab
41-
title: 'Scripts',
42-
// any icon from Iconify, or a URL to an image
43-
icon: 'carbon:script',
44-
// iframe view
45-
view: {
46-
type: 'iframe',
47-
src: DEVTOOLS_UI_ROUTE,
48-
},
49-
})
37+
addCustomTab({
38+
// unique identifier
39+
name: 'nuxt-scripts',
40+
// title to display in the tab
41+
title: 'Scripts',
42+
// any icon from Iconify, or a URL to an image
43+
icon: 'carbon:script',
44+
// iframe view
45+
view: {
46+
type: 'iframe',
47+
src: DEVTOOLS_UI_ROUTE,
48+
},
5049
})
5150
}

0 commit comments

Comments
 (0)