Skip to content

Commit 379c816

Browse files
authoredMay 2, 2022
fix: add tailwindcss types (#462)
1 parent 5e02fec commit 379c816

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed
 

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"dependencies": {
2929
"@nuxt/kit": "npm:@nuxt/kit-edge@latest",
3030
"@nuxt/postcss8": "^1.1.3",
31+
"@types/tailwindcss": "^3.0.10",
3132
"autoprefixer": "^10.4.2",
3233
"chalk": "^4.1.2",
3334
"clear-module": "^4.1.2",

‎playground/app.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
</div>
1010
</template>
1111

12-
<script setup>
12+
<script setup lang="ts">
1313
import tailwindConfig from '#tailwind-config'
1414
</script>

‎src/module.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,17 @@ export default defineNuxtModule({
7171
// Expose resolved tailwind config as an alias
7272
// https://tailwindcss.com/docs/configuration/#referencing-in-javascript
7373
if (moduleOptions.exposeConfig) {
74-
const resolveConfig = await import('tailwindcss/resolveConfig.js').then(r => r.default || r)
74+
const resolveConfig = await import('tailwindcss/resolveConfig.js').then(r => r.default || r) as any
7575
const resolvedConfig = resolveConfig(tailwindConfig)
7676
const template = addTemplate({
7777
filename: 'tailwind.config.mjs',
7878
getContents: () => `export default ${JSON.stringify(resolvedConfig, null, 2)}`
7979
})
80+
addTemplate({
81+
filename: 'tailwind.config.d.ts',
82+
getContents: () => 'declare const config: import("tailwindcss/tailwind-config").TailwindConfig\nexport { config as default }',
83+
write: true
84+
})
8085
nuxt.options.alias['#tailwind-config'] = template.dst
8186
}
8287

@@ -122,9 +127,9 @@ export default defineNuxtModule({
122127
}
123128
addServerMiddleware({ path, handler: viewerDevMiddleware })
124129
nuxt.hook('listen', (_, listener) => {
125-
const fullPath = `${withoutTrailingSlash(listener.url)}${path}`;
126-
logger.info(`Tailwind Viewer: ${chalk.underline.yellow(fullPath)}`);
127-
});
130+
const fullPath = `${withoutTrailingSlash(listener.url)}${path}`
131+
logger.info(`Tailwind Viewer: ${chalk.underline.yellow(fullPath)}`)
132+
})
128133
}
129134
}
130135
})

‎tsconfig.json

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
11
{
2-
"extends": "./playground/.nuxt/tsconfig.json",
3-
"compilerOptions": {
4-
"baseUrl": ".",
5-
"moduleResolution": "Node",
6-
"esModuleInterop": true,
7-
"resolveJsonModule": true,
8-
"types": [
9-
"node"
10-
]
11-
}
2+
"extends": "./playground/.nuxt/tsconfig.json"
123
}

‎yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,11 @@
815815
dependencies:
816816
"@types/node" "*"
817817

818+
"@types/tailwindcss@^3.0.10":
819+
version "3.0.10"
820+
resolved "https://registry.yarnpkg.com/@types/tailwindcss/-/tailwindcss-3.0.10.tgz#cd54bad9c00b4823e9e33c67af585347f235aa11"
821+
integrity sha512-1UnZIHO0NOPyPlPFV0HuMjki2SHkvG9uBA1ZehWj/OQMSROk503nuNyyfmJSIT289yewxTbKoPG+KLxYRvfIIg==
822+
818823
"@types/tough-cookie@*":
819824
version "4.0.1"
820825
resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.1.tgz#8f80dd965ad81f3e1bc26d6f5c727e132721ff40"

0 commit comments

Comments
 (0)
Please sign in to comment.