tailwind-preset-mantine 4.0.0 → 4.0.1

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/README.md CHANGED
@@ -125,6 +125,20 @@ export default {
125
125
  };
126
126
  ```
127
127
 
128
+ Next.js:
129
+
130
+ ```js
131
+ // postcss.config.mjs
132
+ export default {
133
+ plugins: {
134
+ "tailwind-preset-mantine/postcss": {
135
+ input: "./src/mantine-theme.ts",
136
+ },
137
+ "@tailwindcss/postcss": {},
138
+ },
139
+ };
140
+ ```
141
+
128
142
  Vite:
129
143
 
130
144
  ```ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-preset-mantine",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Integrate Mantine with Tailwind CSS",
5
5
  "keywords": [
6
6
  "mantine",
@@ -23,6 +23,8 @@
23
23
  "./theme.css": "./src/theme.css",
24
24
  "./postcss": {
25
25
  "types": "./src/integrations/postcss.d.ts",
26
+ "require": "./src/integrations/postcss.cjs",
27
+ "import": "./src/integrations/postcss.js",
26
28
  "default": "./src/integrations/postcss.js"
27
29
  },
28
30
  "./vite": {
@@ -0,0 +1,85 @@
1
+ const { access } = require("node:fs/promises");
2
+ const { dirname, resolve } = require("node:path");
3
+
4
+ /**
5
+ * @typedef {{
6
+ * input: string;
7
+ * output?: string;
8
+ * format?: "theme" | "standalone";
9
+ * }} MantineThemePluginOptions
10
+ */
11
+
12
+ /**
13
+ * Create a PostCSS plugin factory from a theme output writer.
14
+ *
15
+ * The CJS wrapper uses this helper so the package can expose a `require()`
16
+ * entry without loading the ESM theme graph until PostCSS actually runs.
17
+ *
18
+ * @param {(options: MantineThemePluginOptions, runtimeOptions?: { baseDir?: string }) => Promise<{ dependencies?: string[] }>} writeThemeOutput
19
+ */
20
+ function createMantineThemePostCSS(writeThemeOutput) {
21
+ /**
22
+ * @param {MantineThemePluginOptions} options
23
+ */
24
+ function mantineTheme(options) {
25
+ async function resolveBaseDir(result) {
26
+ const candidates = [];
27
+ const cwd = result.opts.cwd ?? process.cwd();
28
+
29
+ if (result.opts.from) {
30
+ let current = resolve(cwd, result.opts.from);
31
+ current = dirname(current);
32
+
33
+ while (true) {
34
+ candidates.push(current);
35
+ const parent = dirname(current);
36
+
37
+ if (parent === current) {
38
+ break;
39
+ }
40
+
41
+ current = parent;
42
+ }
43
+ }
44
+
45
+ candidates.push(cwd);
46
+
47
+ const dedupedCandidates = [...new Set(candidates)];
48
+
49
+ for (const baseDir of dedupedCandidates) {
50
+ try {
51
+ await access(resolve(baseDir, options.input));
52
+ return baseDir;
53
+ } catch {
54
+ // Try the next candidate directory.
55
+ }
56
+ }
57
+
58
+ return cwd;
59
+ }
60
+
61
+ return {
62
+ postcssPlugin: "tailwind-preset-mantine",
63
+ async Once(_, { result }) {
64
+ const baseDir = await resolveBaseDir(result);
65
+ const { dependencies = [] } = await writeThemeOutput(options, {
66
+ baseDir,
67
+ });
68
+
69
+ for (const file of dependencies) {
70
+ result.messages.push({
71
+ type: "dependency",
72
+ plugin: "tailwind-preset-mantine",
73
+ file,
74
+ parent: result.opts.from,
75
+ });
76
+ }
77
+ },
78
+ };
79
+ }
80
+
81
+ mantineTheme.postcss = true;
82
+ return mantineTheme;
83
+ }
84
+
85
+ module.exports = createMantineThemePostCSS;
@@ -0,0 +1,8 @@
1
+ const createMantineThemePostCSS = require("./postcss-shared.cjs");
2
+
3
+ const mantineTheme = createMantineThemePostCSS(async (...args) => {
4
+ const { writeThemeOutput } = await import("../core/output.js");
5
+ return writeThemeOutput(...args);
6
+ });
7
+
8
+ module.exports = mantineTheme;
@@ -1,75 +1,6 @@
1
- import { access } from "node:fs/promises";
2
- import { dirname, resolve } from "node:path";
1
+ import createMantineThemePostCSS from "./postcss-shared.cjs";
3
2
  import { writeThemeOutput } from "../core/output.js";
4
3
 
5
- /**
6
- * @typedef {{
7
- * input: string;
8
- * output?: string;
9
- * format?: "theme" | "standalone";
10
- * }} MantineThemePluginOptions
11
- */
12
-
13
- /**
14
- * @param {MantineThemePluginOptions} options
15
- */
16
- function mantineTheme(options) {
17
- async function resolveBaseDir(result) {
18
- const candidates = [];
19
- const cwd = result.opts.cwd ?? process.cwd();
20
-
21
- if (result.opts.from) {
22
- let current = resolve(cwd, result.opts.from);
23
- current = dirname(current);
24
-
25
- while (true) {
26
- candidates.push(current);
27
- const parent = dirname(current);
28
-
29
- if (parent === current) {
30
- break;
31
- }
32
-
33
- current = parent;
34
- }
35
- }
36
-
37
- candidates.push(cwd);
38
-
39
- const dedupedCandidates = [...new Set(candidates)];
40
-
41
- for (const baseDir of dedupedCandidates) {
42
- try {
43
- await access(resolve(baseDir, options.input));
44
- return baseDir;
45
- } catch {
46
- // Try the next candidate directory.
47
- }
48
- }
49
-
50
- return cwd;
51
- }
52
-
53
- return {
54
- postcssPlugin: "tailwind-preset-mantine",
55
- async Once(_, { result }) {
56
- const baseDir = await resolveBaseDir(result);
57
- const { dependencies } = await writeThemeOutput(options, {
58
- baseDir,
59
- });
60
-
61
- for (const file of dependencies) {
62
- result.messages.push({
63
- type: "dependency",
64
- plugin: "tailwind-preset-mantine",
65
- file,
66
- parent: result.opts.from,
67
- });
68
- }
69
- },
70
- };
71
- }
72
-
73
- mantineTheme.postcss = true;
4
+ const mantineTheme = createMantineThemePostCSS(writeThemeOutput);
74
5
 
75
6
  export default mantineTheme;