Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tailwind.config.ts support #483

Merged
merged 6 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions docs/content/1.getting-started/1.setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ Discover your color palette based on your Tailwind config with the [Tailwind vie

## Tailwind Files

When running `nuxt dev`, this module will look for these two files:
When running `nuxt dev`, this module will look for these files:

- `./assets/css/tailwind.css`
- `./tailwind.config.js`
- `./tailwind.config.{js,ts}`

If they don't exist, the module will inject a basic configuration for each one so you don't have to create these files.

Expand All @@ -62,6 +62,22 @@ You can configure the paths in the [module options](/getting-started/options).

Learn more about overwriting the Tailwind configuration in the [Tailwind Config](/tailwind/config) section.

## TypeScript (optional)

Officially Tailwind config files are plain JavaScript, however with this module, you can optionally use a TypeScript file for your config.

To do so, rename `tailwind.config.js` to `tailwind.config.ts` and use the types from the tailwindcss module.

```ts [tailwind.config.ts]
import { Config } from 'tailwindcss'

export default <Config> {
theme: {
extend: {}
},
}
```

## Options

You can customize the module's behavior by using the `tailwindcss` property in `nuxt.config`:
Expand Down
1 change: 0 additions & 1 deletion playground/tailwind.config.js

This file was deleted.

6 changes: 6 additions & 0 deletions playground/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Config } from 'tailwindcss'

export default <Config> {
theme: {
},
}
2 changes: 1 addition & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default defineNuxtModule({
configKey: 'tailwindcss'
},
defaults: nuxt => ({
configPath: 'tailwind.config.js',
configPath: 'tailwind.config',
harlan-zw marked this conversation as resolved.
Show resolved Hide resolved
cssPath: join(nuxt.options.dir.assets, 'css/tailwind.css'),
config: defaultTailwindConfig(nuxt.options),
viewer: true,
Expand Down
4 changes: 3 additions & 1 deletion src/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Learn more at https://tailwindcss.com/docs/configuration
export default ({ srcDir }) => ({
import { Config } from 'tailwindcss'

export default ({ srcDir }): Config => ({
theme: {
extend: {}
},
Expand Down