@baybreezy/docd 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/assets/css/tailwind.css +2 -1
- package/modules/css.ts +44 -0
- package/nuxt.config.ts +1 -0
- package/package.json +1 -1
package/modules/css.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { addVitePlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
|
|
2
|
+
import { joinURL } from "ufo";
|
|
3
|
+
|
|
4
|
+
export default defineNuxtModule({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "docd:css",
|
|
7
|
+
},
|
|
8
|
+
setup(_options, nuxt) {
|
|
9
|
+
const resolver = createResolver(import.meta.url);
|
|
10
|
+
|
|
11
|
+
// Absolute path to the layer's tailwind entry — this is the file that owns
|
|
12
|
+
// `@import "tailwindcss"` and therefore controls Tailwind's scanner.
|
|
13
|
+
const tailwindCssPath = resolver.resolve("../app/assets/css/tailwind.css");
|
|
14
|
+
|
|
15
|
+
// The consuming app's content directory. We convert to forward-slashes so
|
|
16
|
+
// the injected @source glob works on Windows too.
|
|
17
|
+
const contentDir = joinURL(nuxt.options.rootDir, "content").replace(/\\/g, "/");
|
|
18
|
+
|
|
19
|
+
// Inject `@source <contentDir>/**/*` into tailwind.css
|
|
20
|
+
addVitePlugin({
|
|
21
|
+
name: "docd:inject-tailwind-sources",
|
|
22
|
+
enforce: "pre",
|
|
23
|
+
transform(code: string, id: string) {
|
|
24
|
+
if (id.split("?")[0] !== tailwindCssPath) return null;
|
|
25
|
+
return {
|
|
26
|
+
code: `${code}\n@source ${JSON.stringify(`${contentDir}/**/*`)};`,
|
|
27
|
+
map: null,
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Suppress noisy Vite warnings produced during Tailwind's build pass.
|
|
33
|
+
nuxt.hook("vite:extendConfig", (config) => {
|
|
34
|
+
const logger = config.customLogger;
|
|
35
|
+
if (!logger) return;
|
|
36
|
+
const ignore = ["@tailwindcss/vite:generate:build", "nuxt:module-preload-polyfill"];
|
|
37
|
+
const originalWarn = logger.warn.bind(logger);
|
|
38
|
+
logger.warn = (msg, options) => {
|
|
39
|
+
if (ignore.some((p) => msg.includes(p))) return;
|
|
40
|
+
originalWarn(msg, options);
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
});
|
package/nuxt.config.ts
CHANGED
|
@@ -50,6 +50,7 @@ export default defineNuxtConfig({
|
|
|
50
50
|
"@morev/vue-transitions/nuxt",
|
|
51
51
|
"vue-sonner/nuxt",
|
|
52
52
|
resolver.resolve("./modules/routing"),
|
|
53
|
+
resolver.resolve("./modules/css"),
|
|
53
54
|
resolver.resolve("./modules/config"),
|
|
54
55
|
resolver.resolve("./modules/custom-icons"),
|
|
55
56
|
resolver.resolve("./modules/prose-component-meta"),
|