From 5d2859afc8563623abb2790fe385bd413b37cf71 Mon Sep 17 00:00:00 2001 From: Inesh Bose <56732164+ineshbose@users.noreply.github.com> Date: Sat, 20 Jan 2024 16:08:57 +0000 Subject: [PATCH 01/23] chore: initial --- playground/nuxt.config.ts | 21 +++- playground/pages/index.vue | 7 +- playground/theme/tailwind.config.cjs | 3 +- src/config.ts | 102 +++++++++++++++++++ src/module.ts | 141 ++++++++++----------------- src/runtime/utils.ts | 26 +++++ src/templates.ts | 6 +- src/types.ts | 6 ++ src/utils.ts | 25 ----- 9 files changed, 213 insertions(+), 124 deletions(-) create mode 100644 src/config.ts delete mode 100644 src/utils.ts diff --git a/playground/nuxt.config.ts b/playground/nuxt.config.ts index d628c5a4..d8ca7137 100644 --- a/playground/nuxt.config.ts +++ b/playground/nuxt.config.ts @@ -1,5 +1,9 @@ import { existsSync } from 'node:fs' import { resolve } from 'pathe' +import { consola } from 'consola' +import type { ModuleHooks, ModuleOptions } from '../src/types' + +const logger = consola.withTag('nuxt:tailwindcss:playground') export default defineNuxtConfig({ extends: ['./theme'], @@ -13,7 +17,22 @@ export default defineNuxtConfig({ exposeConfig: true, cssPath: '~/assets/css/tailwind.css', editorSupport: true - }, + } satisfies Partial, + hooks: { + 'tailwindcss:loadConfig': (config, configPath, idx) => { + logger.info('Running `tailwindcss:loadConfig` hook...', { configPath, idx }) + + if (idx === 0 && config) { + config.theme!.extend = { screens: { 'xs': '100px' }} + } + }, + 'tailwindcss:config': (config) => { + logger.info('Running `tailwindcss:config` hook...') + }, + 'tailwindcss:resolvedConfig': (config) => { + logger.info('Running `tailwindcss:resolvedConfig` hook...') + } + } satisfies Partial, content: { documentDriven: true }, diff --git a/playground/pages/index.vue b/playground/pages/index.vue index 5e85022d..09d6f86c 100644 --- a/playground/pages/index.vue +++ b/playground/pages/index.vue @@ -21,11 +21,11 @@
Resolved tailwind config: -