oklchtohex 0.5.0 → 0.5.2
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 +15 -0
- package/package.json +6 -2
- package/src/postcss-plugin.cjs +28 -0
- package/src/postcss-plugin.js +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,21 @@ export default {
|
|
|
65
65
|
};
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
If your config uses object-style plugins (common in some templates), use:
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
const config = {
|
|
72
|
+
plugins: {
|
|
73
|
+
"@tailwindcss/postcss": {},
|
|
74
|
+
"oklchtohex/postcss": { gamut: "clip" }
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export default config;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
If you previously saw `TypeError: require(...) is not a function`, it was caused by CommonJS loading of an ESM-only plugin path. Use `oklchtohex@0.5.2+` and the config above.
|
|
82
|
+
|
|
68
83
|
For Next.js, keep your standard commands:
|
|
69
84
|
|
|
70
85
|
```json
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oklchtohex",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Convert OKLCH colors to HEX as a JavaScript package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
|
9
9
|
"./vite": "./src/vite-plugin.js",
|
|
10
|
-
"./postcss":
|
|
10
|
+
"./postcss": {
|
|
11
|
+
"import": "./src/postcss-plugin.js",
|
|
12
|
+
"require": "./src/postcss-plugin.cjs",
|
|
13
|
+
"default": "./src/postcss-plugin.js"
|
|
14
|
+
},
|
|
11
15
|
"./converter": "./src/converter.js"
|
|
12
16
|
},
|
|
13
17
|
"files": [
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function oklchToHexPostcssPlugin(options) {
|
|
2
|
+
const pluginOptions = options || {};
|
|
3
|
+
|
|
4
|
+
return {
|
|
5
|
+
postcssPlugin: "oklchtohex-postcss-plugin",
|
|
6
|
+
async Once(root) {
|
|
7
|
+
const originalCss = root.toString();
|
|
8
|
+
if (!originalCss.toLowerCase().includes("oklch(")) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const mod = await import("./converter.js");
|
|
13
|
+
const convertedCss = mod.replaceOklchInText(originalCss, pluginOptions);
|
|
14
|
+
|
|
15
|
+
if (convertedCss !== originalCss) {
|
|
16
|
+
root.removeAll();
|
|
17
|
+
root.append(convertedCss);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
oklchToHexPostcssPlugin.postcss = true;
|
|
24
|
+
|
|
25
|
+
module.exports = oklchToHexPostcssPlugin;
|
|
26
|
+
module.exports.default = oklchToHexPostcssPlugin;
|
|
27
|
+
module.exports.oklchToHexPostcssPlugin = oklchToHexPostcssPlugin;
|
|
28
|
+
|
package/src/postcss-plugin.js
CHANGED