Skip to content

Commit c46c834

Browse files
feat: Adding Tailwind Viewer to Nuxt dev tools (#612)
* feat: tailwindcss viewer in devtools * refactor: ts missing error
1 parent 0c5e073 commit c46c834

File tree

4 files changed

+424
-4
lines changed

4 files changed

+424
-4
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"devDependencies": {
4646
"@fontsource/inter": "^4.5.15",
4747
"@nuxt/content": "^2.4.0",
48+
"@nuxt/devtools": "^0.1.0",
4849
"@nuxt/module-builder": "latest",
4950
"@nuxt/test-utils": "^3.1.1",
5051
"@nuxtjs/eslint-config-typescript": "latest",

playground/nuxt.config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ export default defineNuxtConfig({
22
extends: ['./theme'],
33
modules: [
44
'@nuxt/content',
5-
'../src/module'
5+
'../src/module',
6+
'@nuxt/devtools'
67
],
78
tailwindcss: {
89
exposeConfig: true,

src/module.ts

+16
Original file line numberDiff line numberDiff line change
@@ -314,5 +314,21 @@ export default defineNuxtModule<ModuleOptions>({
314314
logger.info(`Tailwind Viewer: ${chalk.underline.yellow(withTrailingSlash(viewerUrl))}`)
315315
})
316316
}
317+
318+
if (nuxt.options.dev) {
319+
// @ts-expect-error missing type
320+
nuxt.hook('devtools:customTabs', (tabs) => {
321+
tabs.push({
322+
title: 'TailwindCSS',
323+
name: 'tailwindcss',
324+
icon: 'logos-tailwindcss-icon',
325+
view: {
326+
type: 'iframe',
327+
src: '/_tailwind/'
328+
}
329+
})
330+
})
331+
}
317332
}
333+
318334
})

0 commit comments

Comments
 (0)