@csstools/postcss-hwb-function 3.0.8 → 3.0.10

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/CHANGELOG.md CHANGED
@@ -1,26 +1,29 @@
1
1
  # Changes to PostCSS HWB Function
2
2
 
3
- ### 3.0.8
3
+ ### 3.0.10
4
4
 
5
- _December 31, 2023_
5
+ _March 13, 2024_
6
6
 
7
- - Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#223) (patch)
8
- - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.5.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#250) (minor)
9
- - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.5.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#151) (patch)
7
+ - Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.4`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#224) (patch)
8
+ - Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.1.1`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#311) (patch)
9
+ - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.6.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#261) (patch)
10
+ - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.6.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#160) (minor)
10
11
 
11
- ### 3.0.7
12
+ ### 3.0.9
12
13
 
13
- _December 15, 2023_
14
+ _February 19, 2024_
14
15
 
15
- - Skip transforms when a color value contains experimental syntax
16
- - Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#222) (patch)
17
- - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.4.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#240) (minor)
18
- - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.5.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#150) (minor)
16
+ - Reuse code with `@csstools/utilities`
17
+ - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.6.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#260) (minor)
18
+ - Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.1.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#310) (minor)
19
+ - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.5.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#152) (patch)
19
20
 
20
- ### 3.0.6
21
+ ### 3.0.8
21
22
 
22
- _October 9, 2023_
23
+ _December 31, 2023_
23
24
 
24
- - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.4.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#140) (minor)
25
+ - Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#223) (patch)
26
+ - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.5.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#250) (minor)
27
+ - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.5.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#151) (patch)
25
28
 
26
29
  [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-hwb-function/CHANGELOG.md)
package/README.md CHANGED
@@ -1,26 +1,30 @@
1
- # PostCSS HWB Function [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
1
+ # PostCSS HWB Function [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]
2
2
 
3
- [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-hwb-function.svg" height="20">][npm-url]
4
- [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url]
5
- [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
6
- <br><br>
7
- [<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/hwb-function.svg" height="20">][css-url]
8
- [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/hwb-function.svg" height="20">][css-url]
3
+ [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-hwb-function.svg" height="20">][npm-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]<br><br>[<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/hwb-function.svg" height="20">][css-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/hwb-function.svg" height="20">][css-url]
9
4
 
10
- [PostCSS HWB Function] lets you use `hwb` color functions in
11
- CSS, following the [CSS Color] specification.
5
+ ```bash
6
+ npm install @csstools/postcss-hwb-function --save-dev
7
+ ```
8
+
9
+ [PostCSS HWB Function] lets you use the `hwb()` color function in CSS, following [CSS Color Module 4].
12
10
 
13
11
  ```pcss
14
12
  a {
15
13
  color: hwb(194 0% 0%);
14
+ }
15
+
16
+ b {
16
17
  color: hwb(194 0% 0% / .5);
17
18
  }
18
19
 
19
20
  /* becomes */
20
21
 
21
22
  a {
22
- color: rgb(0, 195, 255);
23
- color: rgba(0, 195, 255, .5);
23
+ color: rgb(0, 196, 255);
24
+ }
25
+
26
+ b {
27
+ color: rgba(0, 196, 255, 0.5);
24
28
  }
25
29
  ```
26
30
 
@@ -39,21 +43,26 @@ const postcss = require('postcss');
39
43
  const postcssHWBFunction = require('@csstools/postcss-hwb-function');
40
44
 
41
45
  postcss([
42
- postcssHWBFunction(/* pluginOptions */)
46
+ postcssHWBFunction(/* pluginOptions */)
43
47
  ]).process(YOUR_CSS /*, processOptions */);
44
48
  ```
45
49
 
46
50
  [PostCSS HWB Function] runs in all Node environments, with special
47
51
  instructions for:
48
52
 
49
- | [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
50
- | --- | --- | --- | --- | --- |
53
+ - [Node](INSTALL.md#node)
54
+ - [PostCSS CLI](INSTALL.md#postcss-cli)
55
+ - [PostCSS Load Config](INSTALL.md#postcss-load-config)
56
+ - [Webpack](INSTALL.md#webpack)
57
+ - [Next.js](INSTALL.md#nextjs)
58
+ - [Gulp](INSTALL.md#gulp)
59
+ - [Grunt](INSTALL.md#grunt)
51
60
 
52
61
  ## Options
53
62
 
54
63
  ### preserve
55
64
 
56
- The `preserve` option determines whether the original functional color notation
65
+ The `preserve` option determines whether the original notation
57
66
  is preserved. By default, it is not preserved.
58
67
 
59
68
  ```js
@@ -63,15 +72,21 @@ postcssHWBFunction({ preserve: true })
63
72
  ```pcss
64
73
  a {
65
74
  color: hwb(194 0% 0%);
75
+ }
76
+
77
+ b {
66
78
  color: hwb(194 0% 0% / .5);
67
79
  }
68
80
 
69
81
  /* becomes */
70
82
 
71
83
  a {
72
- color: rgb(0, 195, 255);
84
+ color: rgb(0, 196, 255);
73
85
  color: hwb(194 0% 0%);
74
- color: rgba(0, 195, 255, .5);
86
+ }
87
+
88
+ b {
89
+ color: rgba(0, 196, 255, 0.5);
75
90
  color: hwb(194 0% 0% / .5);
76
91
  }
77
92
  ```
@@ -81,9 +96,6 @@ a {
81
96
  [discord]: https://discord.gg/bUadyRwkJS
82
97
  [npm-url]: https://www.npmjs.com/package/@csstools/postcss-hwb-function
83
98
 
84
- [CSS Color]: https://drafts.csswg.org/css-color/#the-hwb-notation
85
- [Gulp PostCSS]: https://github.com/postcss/gulp-postcss
86
- [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
87
99
  [PostCSS]: https://github.com/postcss/postcss
88
- [PostCSS Loader]: https://github.com/postcss/postcss-loader
89
100
  [PostCSS HWB Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-hwb-function
101
+ [CSS Color Module 4]: https://www.w3.org/TR/css-color-4/#the-hwb-notation
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@csstools/css-color-parser"),t=require("@csstools/css-parser-algorithms"),r=require("@csstools/css-tokenizer");const s="(color: hwb(0 0% 0%))";function hasSupportsAtRuleAncestor(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name.toLowerCase()&&t.params.includes(s))return!0;t=t.parent}else t=t.parent;return!1}function hasFallback(e){const t=e.parent;if(!t)return!1;const r=e.prop.toLowerCase(),s=t.index(e);for(let e=0;e<s;e++){const s=t.nodes[e];if("decl"===s.type&&s.prop.toLowerCase()===r)return!0}return!1}const o=/hwb\(/i,a=/^hwb$/i,postcssPlugin=n=>{const l="preserve"in Object(n)&&Boolean(n?.preserve);return{postcssPlugin:"postcss-hwb-function",Declaration:(n,{postcss:p})=>{const c=n.value;if(!o.test(c))return;if(l&&hasSupportsAtRuleAncestor(n))return;if(hasFallback(n))return;const u=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(r.tokenize({css:c})),(r=>{if(!t.isFunctionNode(r)||!a.test(r.getName()))return;const s=e.color(r);return s&&!(s.syntaxFlags.has(e.SyntaxFlag.Experimental)||s.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords)||s.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax))?e.serializeRGB(s):void 0})),i=t.stringify(u);if(i!==c)if(n.variable&&l&&n.parent){const e=n.parent,t=p.atRule({name:"supports",params:s,source:n.source}),r=e.clone();r.removeAll(),r.append(n.clone()),t.append(r),insertAtSupportsAfterCorrectRule(t,e,s),n.replaceWith(n.clone({value:i}))}else l?n.cloneBefore({value:i}):n.replaceWith(n.clone({value:i}))}}};function insertAtSupportsAfterCorrectRule(e,t,r){let s=t,o=t.next();for(;s&&o&&"atrule"===o.type&&"supports"===o.name.toLowerCase()&&o.params===r;)s=o,o=o.next();s.after(e)}postcssPlugin.postcss=!0,module.exports=postcssPlugin;
1
+ "use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/css-color-parser"),t=require("@csstools/utilities"),r=require("@csstools/css-parser-algorithms"),o=require("@csstools/css-tokenizer");const a=/\bhwb\(/i,n=/^hwb$/i,basePlugin=s=>({postcssPlugin:"postcss-hwb-function",Declaration(i){const c=i.value;if(!a.test(c))return;if(t.hasFallback(i))return;if(t.hasSupportsAtRuleAncestor(i,a))return;const l=r.replaceComponentValues(r.parseCommaSeparatedListOfComponentValues(o.tokenize({css:c})),(s=>{if(!r.isFunctionNode(s)||!n.test(s.getName()))return;const t=e.color(s);return t&&!(t.syntaxFlags.has(e.SyntaxFlag.Experimental)||t.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords)||t.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax))?e.serializeRGB(t):void 0})),u=r.stringify(l);u!==c&&(i.cloneBefore({value:u}),s?.preserve||i.remove())}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},e);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-hwb-function",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,17 @@
1
1
  import type { PluginCreator } from 'postcss';
2
2
 
3
+ /** postcss-hwb-function plugin options */
4
+ export declare type basePluginOptions = {
5
+ /** Preserve the original notation. default: false */
6
+ preserve?: boolean;
7
+ };
8
+
3
9
  /** postcss-hwb-function plugin options */
4
10
  export declare type pluginOptions = {
5
11
  /** Preserve the original notation. default: false */
6
12
  preserve?: boolean;
13
+ /** Enable "@csstools/postcss-progressive-custom-properties". default: true */
14
+ enableProgressiveCustomProperties?: boolean;
7
15
  };
8
16
 
9
17
  /** Transform hwb() functions in CSS. */
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{color as e,SyntaxFlag as t,serializeRGB as r}from"@csstools/css-color-parser";import{replaceComponentValues as s,parseCommaSeparatedListOfComponentValues as o,isFunctionNode as n,stringify as a}from"@csstools/css-parser-algorithms";import{tokenize as p}from"@csstools/css-tokenizer";const l="(color: hwb(0 0% 0%))";function hasSupportsAtRuleAncestor(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name.toLowerCase()&&t.params.includes(l))return!0;t=t.parent}else t=t.parent;return!1}function hasFallback(e){const t=e.parent;if(!t)return!1;const r=e.prop.toLowerCase(),s=t.index(e);for(let e=0;e<s;e++){const s=t.nodes[e];if("decl"===s.type&&s.prop.toLowerCase()===r)return!0}return!1}const c=/hwb\(/i,u=/^hwb$/i,postcssPlugin=i=>{const f="preserve"in Object(i)&&Boolean(i?.preserve);return{postcssPlugin:"postcss-hwb-function",Declaration:(i,{postcss:m})=>{const h=i.value;if(!c.test(h))return;if(f&&hasSupportsAtRuleAncestor(i))return;if(hasFallback(i))return;const v=s(o(p({css:h})),(s=>{if(!n(s)||!u.test(s.getName()))return;const o=e(s);return o&&!(o.syntaxFlags.has(t.Experimental)||o.syntaxFlags.has(t.HasNoneKeywords)||o.syntaxFlags.has(t.RelativeColorSyntax))?r(o):void 0})),d=a(v);if(d!==h)if(i.variable&&f&&i.parent){const e=i.parent,t=m.atRule({name:"supports",params:l,source:i.source}),r=e.clone();r.removeAll(),r.append(i.clone()),t.append(r),insertAtSupportsAfterCorrectRule(t,e,l),i.replaceWith(i.clone({value:d}))}else f?i.cloneBefore({value:d}):i.replaceWith(i.clone({value:d}))}}};function insertAtSupportsAfterCorrectRule(e,t,r){let s=t,o=t.next();for(;s&&o&&"atrule"===o.type&&"supports"===o.name.toLowerCase()&&o.params===r;)s=o,o=o.next();s.after(e)}postcssPlugin.postcss=!0;export{postcssPlugin as default};
1
+ import s from"@csstools/postcss-progressive-custom-properties";import{color as o,SyntaxFlag as e,serializeRGB as t}from"@csstools/css-color-parser";import{hasFallback as r,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as c,isFunctionNode as a,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as l}from"@csstools/css-tokenizer";const u=/\bhwb\(/i,m=/^hwb$/i,basePlugin=s=>({postcssPlugin:"postcss-hwb-function",Declaration(f){const g=f.value;if(!u.test(g))return;if(r(f))return;if(i(f,u))return;const v=n(c(l({css:g})),(s=>{if(!a(s)||!m.test(s.getName()))return;const r=o(s);return r&&!(r.syntaxFlags.has(e.Experimental)||r.syntaxFlags.has(e.HasNoneKeywords)||r.syntaxFlags.has(e.RelativeColorSyntax))?t(r):void 0})),b=p(v);b!==g&&(f.cloneBefore({value:b}),s?.preserve||f.remove())}});basePlugin.postcss=!0;const postcssPlugin=o=>{const e=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},o);return e.enableProgressiveCustomProperties&&e.preserve?{postcssPlugin:"postcss-hwb-function",plugins:[s(),basePlugin(e)]}:basePlugin(e)};postcssPlugin.postcss=!0;export{postcssPlugin as default};
package/package.json CHANGED
@@ -1,8 +1,18 @@
1
1
  {
2
2
  "name": "@csstools/postcss-hwb-function",
3
3
  "description": "Use hwb() color functions in CSS",
4
- "version": "3.0.8",
5
- "author": "Jonathan Neal <jonathantneal@hotmail.com>",
4
+ "version": "3.0.10",
5
+ "contributors": [
6
+ {
7
+ "name": "Antonio Laguna",
8
+ "email": "antonio@laguna.es",
9
+ "url": "https://antonio.laguna.es"
10
+ },
11
+ {
12
+ "name": "Romain Menke",
13
+ "email": "romainmenke@gmail.com"
14
+ }
15
+ ],
6
16
  "license": "MIT-0",
7
17
  "funding": [
8
18
  {
@@ -33,15 +43,16 @@
33
43
  },
34
44
  "files": [
35
45
  "CHANGELOG.md",
36
- "INSTALL.md",
37
46
  "LICENSE.md",
38
47
  "README.md",
39
48
  "dist"
40
49
  ],
41
50
  "dependencies": {
42
- "@csstools/css-color-parser": "^1.5.1",
43
- "@csstools/css-parser-algorithms": "^2.5.0",
44
- "@csstools/css-tokenizer": "^2.2.3"
51
+ "@csstools/css-color-parser": "^1.6.0",
52
+ "@csstools/css-parser-algorithms": "^2.6.1",
53
+ "@csstools/css-tokenizer": "^2.2.4",
54
+ "@csstools/postcss-progressive-custom-properties": "^3.1.1",
55
+ "@csstools/utilities": "^1.0.0"
45
56
  },
46
57
  "peerDependencies": {
47
58
  "postcss": "^8.4"
@@ -49,25 +60,18 @@
49
60
  "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-hwb-function#readme",
50
61
  "repository": {
51
62
  "type": "git",
52
- "url": "https://github.com/csstools/postcss-plugins.git",
63
+ "url": "git+https://github.com/csstools/postcss-plugins.git",
53
64
  "directory": "plugins/postcss-hwb-function"
54
65
  },
55
66
  "bugs": "https://github.com/csstools/postcss-plugins/issues",
56
67
  "keywords": [
57
68
  "color",
58
- "comma",
59
69
  "css",
60
70
  "design",
61
- "functional",
62
- "hsl",
63
- "hsla",
64
71
  "hwb",
65
72
  "notation",
66
73
  "postcss",
67
74
  "postcss-plugin",
68
- "rgb",
69
- "rgba",
70
- "space",
71
75
  "syntax"
72
76
  ]
73
77
  }
package/INSTALL.md DELETED
@@ -1,235 +0,0 @@
1
- # Installing PostCSS HWB Function
2
-
3
- [PostCSS HWB Function] runs in all Node environments, with special instructions for:
4
-
5
- - [Node](#node)
6
- - [PostCSS CLI](#postcss-cli)
7
- - [PostCSS Load Config](#postcss-load-config)
8
- - [Webpack](#webpack)
9
- - [Next.js](#nextjs)
10
- - [Gulp](#gulp)
11
- - [Grunt](#grunt)
12
-
13
-
14
-
15
- ## Node
16
-
17
- Add [PostCSS HWB Function] to your project:
18
-
19
- ```bash
20
- npm install postcss @csstools/postcss-hwb-function --save-dev
21
- ```
22
-
23
- Use it as a [PostCSS] plugin:
24
-
25
- ```js
26
- // commonjs
27
- const postcss = require('postcss');
28
- const postcssHWBFunction = require('@csstools/postcss-hwb-function');
29
-
30
- postcss([
31
- postcssHWBFunction(/* pluginOptions */)
32
- ]).process(YOUR_CSS /*, processOptions */);
33
- ```
34
-
35
- ```js
36
- // esm
37
- import postcss from 'postcss';
38
- import postcssHWBFunction from '@csstools/postcss-hwb-function';
39
-
40
- postcss([
41
- postcssHWBFunction(/* pluginOptions */)
42
- ]).process(YOUR_CSS /*, processOptions */);
43
- ```
44
-
45
- ## PostCSS CLI
46
-
47
- Add [PostCSS CLI] to your project:
48
-
49
- ```bash
50
- npm install postcss-cli @csstools/postcss-hwb-function --save-dev
51
- ```
52
-
53
- Use [PostCSS HWB Function] in your `postcss.config.js` configuration file:
54
-
55
- ```js
56
- const postcssHWBFunction = require('@csstools/postcss-hwb-function');
57
-
58
- module.exports = {
59
- plugins: [
60
- postcssHWBFunction(/* pluginOptions */)
61
- ]
62
- }
63
- ```
64
-
65
- ## PostCSS Load Config
66
-
67
- If your framework/CLI supports [`postcss-load-config`](https://github.com/postcss/postcss-load-config).
68
-
69
- ```bash
70
- npm install @csstools/postcss-hwb-function --save-dev
71
- ```
72
-
73
- `package.json`:
74
-
75
- ```json
76
- {
77
- "postcss": {
78
- "plugins": {
79
- "@csstools/postcss-hwb-function": {}
80
- }
81
- }
82
- }
83
- ```
84
-
85
- `.postcssrc.json`:
86
-
87
- ```json
88
- {
89
- "plugins": {
90
- "@csstools/postcss-hwb-function": {}
91
- }
92
- }
93
- ```
94
-
95
- _See the [README of `postcss-load-config`](https://github.com/postcss/postcss-load-config#usage) for more usage options._
96
-
97
- ## Webpack
98
-
99
- _Webpack version 5_
100
-
101
- Add [PostCSS Loader] to your project:
102
-
103
- ```bash
104
- npm install postcss-loader @csstools/postcss-hwb-function --save-dev
105
- ```
106
-
107
- Use [PostCSS HWB Function] in your Webpack configuration:
108
-
109
- ```js
110
- module.exports = {
111
- module: {
112
- rules: [
113
- {
114
- test: /\.css$/i,
115
- use: [
116
- "style-loader",
117
- {
118
- loader: "css-loader",
119
- options: { importLoaders: 1 },
120
- },
121
- {
122
- loader: "postcss-loader",
123
- options: {
124
- postcssOptions: {
125
- plugins: [
126
- // Other plugins,
127
- [
128
- "@csstools/postcss-hwb-function",
129
- {
130
- // Options
131
- },
132
- ],
133
- ],
134
- },
135
- },
136
- },
137
- ],
138
- },
139
- ],
140
- },
141
- };
142
- ```
143
-
144
- ## Next.js
145
-
146
- Read the instructions on how to [customize the PostCSS configuration in Next.js](https://nextjs.org/docs/advanced-features/customizing-postcss-config)
147
-
148
- ```bash
149
- npm install @csstools/postcss-hwb-function --save-dev
150
- ```
151
-
152
- Use [PostCSS HWB Function] in your `postcss.config.json` file:
153
-
154
- ```json
155
- {
156
- "plugins": [
157
- "@csstools/postcss-hwb-function"
158
- ]
159
- }
160
- ```
161
-
162
- ```json5
163
- {
164
- "plugins": [
165
- [
166
- "@csstools/postcss-hwb-function",
167
- {
168
- // Optionally add plugin options
169
- }
170
- ]
171
- ]
172
- }
173
- ```
174
-
175
- ## Gulp
176
-
177
- Add [Gulp PostCSS] to your project:
178
-
179
- ```bash
180
- npm install gulp-postcss @csstools/postcss-hwb-function --save-dev
181
- ```
182
-
183
- Use [PostCSS HWB Function] in your Gulpfile:
184
-
185
- ```js
186
- const postcss = require('gulp-postcss');
187
- const postcssHWBFunction = require('@csstools/postcss-hwb-function');
188
-
189
- gulp.task('css', function () {
190
- var plugins = [
191
- postcssHWBFunction(/* pluginOptions */)
192
- ];
193
-
194
- return gulp.src('./src/*.css')
195
- .pipe(postcss(plugins))
196
- .pipe(gulp.dest('.'));
197
- });
198
- ```
199
-
200
- ## Grunt
201
-
202
- Add [Grunt PostCSS] to your project:
203
-
204
- ```bash
205
- npm install grunt-postcss @csstools/postcss-hwb-function --save-dev
206
- ```
207
-
208
- Use [PostCSS HWB Function] in your Gruntfile:
209
-
210
- ```js
211
- const postcssHWBFunction = require('@csstools/postcss-hwb-function');
212
-
213
- grunt.loadNpmTasks('grunt-postcss');
214
-
215
- grunt.initConfig({
216
- postcss: {
217
- options: {
218
- processors: [
219
- postcssHWBFunction(/* pluginOptions */)
220
- ]
221
- },
222
- dist: {
223
- src: '*.css'
224
- }
225
- }
226
- });
227
- ```
228
-
229
- [Gulp PostCSS]: https://github.com/postcss/gulp-postcss
230
- [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
231
- [PostCSS]: https://github.com/postcss/postcss
232
- [PostCSS CLI]: https://github.com/postcss/postcss-cli
233
- [PostCSS Loader]: https://github.com/postcss/postcss-loader
234
- [PostCSS HWB Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-hwb-function
235
- [Next.js]: https://nextjs.org