oklchtohex 0.6.2 → 0.7.0
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 +26 -24
- package/dist/index.js +1 -1
- package/dist/next-plugin.cjs +1 -0
- package/dist/next-plugin.js +1 -0
- package/package.json +7 -7
- package/dist/postcss-plugin.cjs +0 -1
- package/dist/postcss-plugin.js +0 -1
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ Built for teams using Tailwind v4 who want HEX values in generated CSS for QA, c
|
|
|
12
12
|
|
|
13
13
|
- Converts `oklch(...)` to HEX (`#RRGGBB` / `#RRGGBBAA`)
|
|
14
14
|
- Works as a Vite plugin (auto-convert in `dev` and `build`)
|
|
15
|
+
- Works with Next.js via `next.config` wrapper
|
|
15
16
|
- Works as a plain JS utility for custom build scripts
|
|
16
17
|
- Handles Tailwind default color variables with exact palette HEX values
|
|
17
18
|
- Handles Tailwind slash opacity utilities like `border-red-500/30`
|
|
@@ -47,40 +48,41 @@ Default behavior:
|
|
|
47
48
|
|
|
48
49
|
No changes are required to your existing `dev` or `build` commands.
|
|
49
50
|
|
|
50
|
-
##
|
|
51
|
+
## Next.js (`next.config` wrapper)
|
|
51
52
|
|
|
52
|
-
Use the
|
|
53
|
+
Use the Next wrapper export to auto-convert emitted CSS.
|
|
53
54
|
|
|
54
|
-
`
|
|
55
|
+
`next.config.js`:
|
|
55
56
|
|
|
56
57
|
```js
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
58
|
+
const { withOklchToHexNext } = require("oklchtohex/next");
|
|
59
|
+
|
|
60
|
+
module.exports = withOklchToHexNext(
|
|
61
|
+
{
|
|
62
|
+
// your existing Next config
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
gamut: "clip"
|
|
66
|
+
}
|
|
67
|
+
);
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
|
|
70
|
+
or ESM `next.config.mjs`:
|
|
69
71
|
|
|
70
72
|
```js
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
import { withOklchToHexNext } from "oklchtohex/next";
|
|
74
|
+
|
|
75
|
+
export default withOklchToHexNext(
|
|
76
|
+
{
|
|
77
|
+
// your existing Next config
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
gamut: "clip"
|
|
75
81
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
export default config;
|
|
82
|
+
);
|
|
79
83
|
```
|
|
80
84
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
For Next.js, keep your standard commands:
|
|
85
|
+
Keep your standard commands:
|
|
84
86
|
|
|
85
87
|
```json
|
|
86
88
|
{
|
|
@@ -203,7 +205,7 @@ Yes. Custom theme variables are converted first, then opacity utilities emitted
|
|
|
203
205
|
|
|
204
206
|
### Can I use this without Vite?
|
|
205
207
|
|
|
206
|
-
Yes. Use
|
|
208
|
+
Yes. Use Next wrapper (`oklchtohex/next`) or JS API (`replaceOklchInText` / `convertTailwindCssToHex`) in any Node-based build step.
|
|
207
209
|
|
|
208
210
|
### What if a color token cannot be parsed?
|
|
209
211
|
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./converter.js";import{oklchToHexVitePlugin as t}from"./vite-plugin.js";import{
|
|
1
|
+
export*from"./converter.js";import{oklchToHexVitePlugin as t}from"./vite-plugin.js";import{withOklchToHexNext as f}from"./next-plugin.js";export{t as oklchToHexVitePlugin,f as withOklchToHexNext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f=Object.create;var u=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var b=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of x(e))!S.call(t,s)&&s!==o&&u(t,s,{get:()=>e[s],enumerable:!(n=w(e,s))||n.enumerable});return t};var m=(t,e,o)=>(o=t!=null?f(g(t)):{},b(e||!t||!t.__esModule?u(o,"default",{value:t,enumerable:!0}):o,t));class d{constructor(e){this.options=e||{}}apply(e){const o="oklchtohex-next-webpack-plugin",{Compilation:n,sources:s}=e.webpack;let i;e.hooks.thisCompilation.tap(o,c=>{c.hooks.processAssets.tapPromise({name:o,stage:n.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE},async h=>{for(const[r,k]of Object.entries(h)){if(!r.endsWith(".css"))continue;const p=k.source().toString();if(!p.toLowerCase().includes("oklch("))continue;i||(i=import("./converter.js"));const l=(await i).replaceOklchInText(p,this.options);l!==p&&c.updateAsset(r,new s.RawSource(l))}})})}}function a(t,e){const o=t||{};return{...o,webpack(n,s){const i=typeof o.webpack=="function"?o.webpack:null,c=i?i(n,s):n;return c.plugins=c.plugins||[],c.plugins.push(new d(e)),c}}}module.exports=a,module.exports.default=a,module.exports.withOklchToHexNext=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{replaceOklchInText as l}from"./converter.js";class k{constructor(s={}){this.options=s}apply(s){const t="oklchtohex-next-webpack-plugin",{Compilation:c,sources:n}=s.webpack;s.hooks.thisCompilation.tap(t,e=>{e.hooks.processAssets.tap({name:t,stage:c.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE},u=>{for(const[p,r]of Object.entries(u)){if(!p.endsWith(".css"))continue;const i=r.source().toString();if(!i.toLowerCase().includes("oklch("))continue;const a=l(i,this.options);a!==i&&e.updateAsset(p,new n.RawSource(a))}})})}}function w(o={},s={}){return{...o,webpack(t,c){const n=typeof o.webpack=="function"?o.webpack:null,e=n?n(t,c):t;return e.plugins=e.plugins||[],e.plugins.push(new k(s)),e}}}export{w as withOklchToHexNext};
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oklchtohex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Convert OKLCH colors to HEX as a JavaScript package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./dist/index.js",
|
|
9
9
|
"./vite": "./dist/vite-plugin.js",
|
|
10
|
-
"./
|
|
11
|
-
"import": "./dist/
|
|
12
|
-
"require": "./dist/
|
|
13
|
-
"default": "./dist/
|
|
10
|
+
"./next": {
|
|
11
|
+
"import": "./dist/next-plugin.js",
|
|
12
|
+
"require": "./dist/next-plugin.cjs",
|
|
13
|
+
"default": "./dist/next-plugin.js"
|
|
14
14
|
},
|
|
15
15
|
"./converter": "./dist/converter.js"
|
|
16
16
|
},
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"tailwindcss",
|
|
33
33
|
"vite",
|
|
34
34
|
"vite-plugin",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
35
|
+
"nextjs",
|
|
36
|
+
"webpack",
|
|
37
37
|
"color",
|
|
38
38
|
"converter"
|
|
39
39
|
],
|
package/dist/postcss-plugin.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var p=Object.create;var i=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var a=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var x=(s,o,t,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of u(o))!g.call(s,n)&&n!==t&&i(s,n,{get:()=>o[n],enumerable:!(e=r(o,n))||e.enumerable});return s};var d=(s,o,t)=>(t=s!=null?p(a(s)):{},x(o||!s||!s.__esModule?i(t,"default",{value:s,enumerable:!0}):t,s));function c(s){const o=s||{};return{postcssPlugin:"oklchtohex-postcss-plugin",async Once(t){const e=t.toString();if(!e.toLowerCase().includes("oklch("))return;const l=(await import("./converter.js")).replaceOklchInText(e,o);l!==e&&(t.removeAll(),t.append(l))}}}c.postcss=!0,module.exports=c,module.exports.default=c,module.exports.oklchToHexPostcssPlugin=c;
|
package/dist/postcss-plugin.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{replaceOklchInText as c}from"./converter.js";function t(n={}){return{postcssPlugin:"oklchtohex-postcss-plugin",Once(e){const s=e.toString();if(!s.toLowerCase().includes("oklch("))return;const o=c(s,n);o!==s&&(e.removeAll(),e.append(o))}}}t.postcss=!0;var r=t;export{r as default,t as oklchToHexPostcssPlugin};
|