@tailwind-merge/vite 0.0.0-dev.50b1d1e9f69ac68604be38dabea94cccdc6b070a

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Dany Castillo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @tailwind-merge/vite
2
+
3
+ A [Vite](https://vite.dev) plugin that configures [tailwind-merge](https://github.com/dcastil/tailwind-merge) for your project's own [Tailwind CSS](https://tailwindcss.com) theme — automatically, at build time, with nothing to maintain by hand.
4
+
5
+ ```ts
6
+ // vite.config.ts
7
+ import tailwindcss from '@tailwindcss/vite'
8
+ import tailwindMerge from '@tailwind-merge/vite'
9
+
10
+ export default {
11
+ plugins: [tailwindcss(), tailwindMerge()],
12
+ }
13
+ ```
14
+
15
+ ```ts
16
+ import { twMerge } from '@tailwind-merge/vite/runtime'
17
+
18
+ // With `--text-huge: 2.5rem` in your @theme:
19
+ twMerge('text-huge text-sm')
20
+ // → 'text-sm' — plain tailwind-merge would keep both, misreading text-huge as a color
21
+ ```
22
+
23
+ - Zero configuration: your Tailwind CSS entrypoint is auto-detected, the merge config is generated from the theme Tailwind actually resolves
24
+ - One package to add: tailwind-merge is supplied as the plugin's runtime dependency
25
+ - Nothing written to disk: the generated module is served in-memory, so no checked-in artifacts and no TypeScript-server churn
26
+ - Quiet in development: the config regenerates only when your Tailwind configuration changes, and reloads only when the result actually differs
27
+ - Small in production: the config is pruned to the classes found in your sources — the same files Tailwind scans — with substantial savings in the [measured project samples](https://github.com/dcastil/tailwind-merge/blob/50b1d1e9f69ac68604be38dabea94cccdc6b070a/agents/configurator-performance.md)
28
+ - Declares support for Vite 6–8 and the Tailwind CSS v4.3 line; see [coverage limits](https://github.com/dcastil/tailwind-merge/blob/50b1d1e9f69ac68604be38dabea94cccdc6b070a/packages/vite/docs/limitations.md)
29
+
30
+ > **Status: pre-release, pre-1.0.** There is no stable release yet. Dev builds of every commit on `main` are published to npm under the `dev` tag for evaluation — see [Getting started](https://github.com/dcastil/tailwind-merge/blob/50b1d1e9f69ac68604be38dabea94cccdc6b070a/packages/vite/docs/getting-started.md#availability-and-installation). Treat the plugin as not production-ready until 1.0.0 — see [Versioning](https://github.com/dcastil/tailwind-merge/blob/50b1d1e9f69ac68604be38dabea94cccdc6b070a/packages/vite/docs/versioning.md).
31
+
32
+ ## Get started
33
+
34
+ - [What is it for](https://github.com/dcastil/tailwind-merge/blob/50b1d1e9f69ac68604be38dabea94cccdc6b070a/packages/vite/docs/what-is-it-for.md)
35
+ - [Getting started](https://github.com/dcastil/tailwind-merge/blob/50b1d1e9f69ac68604be38dabea94cccdc6b070a/packages/vite/docs/getting-started.md)
36
+ - [How it works](https://github.com/dcastil/tailwind-merge/blob/50b1d1e9f69ac68604be38dabea94cccdc6b070a/packages/vite/docs/how-it-works.md)
37
+ - [API reference](https://github.com/dcastil/tailwind-merge/blob/50b1d1e9f69ac68604be38dabea94cccdc6b070a/packages/vite/docs/api-reference.md)
38
+ - [Limitations](https://github.com/dcastil/tailwind-merge/blob/50b1d1e9f69ac68604be38dabea94cccdc6b070a/packages/vite/docs/limitations.md)
39
+ - [Versioning](https://github.com/dcastil/tailwind-merge/blob/50b1d1e9f69ac68604be38dabea94cccdc6b070a/packages/vite/docs/versioning.md)
40
+
41
+ For work on the plugin itself, read the [Vite development guide](https://github.com/dcastil/tailwind-merge/blob/50b1d1e9f69ac68604be38dabea94cccdc6b070a/agents/vite-plugin.md).
@@ -0,0 +1,58 @@
1
+ import { Plugin } from "vite";
2
+ //#region src/updates.d.ts
3
+ type UpdateTrigger = 'config' | 'sources';
4
+ //#endregion
5
+ //#region src/index.d.ts
6
+ interface TailwindMergeOptions {
7
+ /** Path to the project's Tailwind CSS entrypoint, relative to the Vite root. When omitted, the entrypoint is auto-detected within the root. Set this to disambiguate themes or select an entrypoint outside the discovery scan. */
8
+ css?: string;
9
+ /** LRU cache size of the generated `twMerge`, passed through to the generated config. Defaults to tailwind-merge's default. */
10
+ cacheSize?: number;
11
+ /** How theme scales are encoded in the generated config: `'compact'` (default) picks the smallest matcher even when it accepts names beyond the theme, `'exact'` enumerates finite names to avoid that overmatching, at a size cost; arbitrary-value types remain approximate. See the configurator's docs for the tradeoff. */
12
+ encoding?: 'compact' | 'exact';
13
+ /**
14
+ * Prunes the generated config to the classes found in your sources — the same files Tailwind scans, found the same way — so production bundles ship only the class groups and scale values the project uses. Lists composed of scanned candidates merge exactly like with the full generated config; retained validators may also match unscanned names.
15
+ *
16
+ * `true` (the default, except in library mode): prune in `vite build`, serve the full config in dev. `false`: never prune — for projects whose class names reach `twMerge` from outside the scanned sources *and* get their styles from somewhere else than this Tailwind build (server-delivered markup, module federation). The object form configures the details.
17
+ */
18
+ prune?: boolean | PruneOptions;
19
+ }
20
+ interface PruneOptions {
21
+ /** Prune production builds. Defaults to `true` — except in library mode (`build.lib`), where the consuming app's classes can't be scanned and the default is `false`. */
22
+ build?: boolean;
23
+ /** Also prune in the dev server, for debugging differences between dev and build: every source edit that changes the used classes then regenerates and reloads. Defaults to `false`. */
24
+ dev?: boolean;
25
+ /** Log one line per generation saying what pruning did. Defaults to `true`. */
26
+ log?: boolean;
27
+ }
28
+ /**
29
+ * What the dev server did in reaction to a file change, reported through `TailwindMergePluginApi.onUpdate` once the plugin has finished processing the change (debounce, regeneration or re-scan, invalidation).
30
+ */
31
+ interface PluginUpdate {
32
+ /** Which kind of file changed: one of the CSS graph (`'config'`), or — with `prune.dev` — any other watched file, which may be a source (`'sources'`). */
33
+ trigger: UpdateTrigger;
34
+ /** Whether a new module was generated. False when a sources change left the used classes unchanged, and when generation failed and the previous module stays in service. */
35
+ regenerated: boolean;
36
+ /** Whether the served module changed and a full reload was sent. False when regeneration produced identical output — the stability gate. */
37
+ reloaded: boolean;
38
+ }
39
+ /**
40
+ * The plugin's `api` object (Vite's convention for what a plugin exposes to other plugins and tooling). Lets tooling — and this package's own tests — learn when the dev server has finished reacting to an edit instead of guessing with timeouts.
41
+ */
42
+ interface TailwindMergePluginApi {
43
+ /** Subscribes to the dev server's reactions to file changes. Returns the unsubscribe function. */
44
+ onUpdate(listener: (update: PluginUpdate) => void): () => void;
45
+ }
46
+ /**
47
+ * Vite plugin that configures tailwind-merge for the project's own Tailwind CSS.
48
+ *
49
+ * Add it next to `@tailwindcss/vite` and import from the runtime subpath: `import { twMerge } from '@tailwind-merge/vite/runtime'`. While Vite runs, that import resolves to an in-memory module generated from the project's Tailwind theme by @tailwind-merge/configurator; outside Vite it resolves to the real runtime.ts and serves default tailwind-merge behavior. Repository integration goals and invariants live in agents/vite-plugin.md.
50
+ *
51
+ * The dev loop is deliberately quiet: generation reads only the CSS configuration (never which classes the app uses, unless `prune.dev` asks for it), regenerates only when a file of the CSS graph changes, and even then triggers a full reload only when the generated module actually changed — editing utility classes in app.css causes no churn. Production builds additionally prune the config to the classes found in the project's sources (`prune` option).
52
+ */
53
+ declare function tailwindMerge(options?: TailwindMergeOptions): Plugin & {
54
+ api: TailwindMergePluginApi;
55
+ };
56
+ //#endregion
57
+ export { PluginUpdate, PruneOptions, TailwindMergeOptions, TailwindMergePluginApi, tailwindMerge as default };
58
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/updates.ts","../src/index.ts"],"mappings":";;KAAY;;;UCiBK;;EAEb;;EAEA;;EAEA;;;;;;EAMA,kBAAkB;;UAGL;;EAEb;;EAEA;;EAEA;;;;;UAMa;;EAEb,SAAS;;EAET;;EAEA;;;;;UAMa;;EAEb,SAAS,WAAW,QAAQ;;;;;;;;;iBAUR,cACpB,UAAS,uBACV;EAAW,KAAK"}