@csstools/postcss-hwb-function 3.0.7 → 3.0.9

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,24 +1,29 @@
1
1
  # Changes to PostCSS HWB Function
2
2
 
3
- ### 3.0.7
3
+ ### 3.0.9
4
4
 
5
- _December 15, 2023_
5
+ _February 19, 2024_
6
6
 
7
- - Skip transforms when a color value contains experimental syntax
8
- - 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)
9
- - 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)
10
- - 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)
7
+ - Reuse code with `@csstools/utilities`
8
+ - 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)
9
+ - 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)
10
+ - 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)
11
11
 
12
- ### 3.0.6
12
+ ### 3.0.8
13
13
 
14
- _October 9, 2023_
14
+ _December 31, 2023_
15
15
 
16
- - 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)
16
+ - 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)
17
+ - 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)
18
+ - 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)
17
19
 
18
- ### 3.0.5
20
+ ### 3.0.7
19
21
 
20
- _October 2, 2023_
22
+ _December 15, 2023_
21
23
 
22
- - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#133) (patch)
24
+ - Skip transforms when a color value contains experimental syntax
25
+ - 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)
26
+ - 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)
27
+ - 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)
23
28
 
24
29
  [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-hwb-function/CHANGELOG.md)
package/README.md CHANGED
@@ -1,25 +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="CSS Standard Status" src="https://cssdb.org/images/badges/hwb-function.svg" height="20">][css-url]
5
- [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url]
6
- [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
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]
7
4
 
5
+ ```bash
6
+ npm install @csstools/postcss-hwb-function --save-dev
7
+ ```
8
8
 
9
- [PostCSS HWB Function] lets you use `hwb` color functions in
10
- CSS, following the [CSS Color] specification.
9
+ [PostCSS HWB Function] lets you use the `hwb()` color function in CSS, following [CSS Color Module 4].
11
10
 
12
11
  ```pcss
13
12
  a {
14
13
  color: hwb(194 0% 0%);
14
+ }
15
+
16
+ b {
15
17
  color: hwb(194 0% 0% / .5);
16
18
  }
17
19
 
18
20
  /* becomes */
19
21
 
20
22
  a {
21
- color: rgb(0, 195, 255);
22
- color: rgba(0, 195, 255, .5);
23
+ color: rgb(0, 196, 255);
24
+ }
25
+
26
+ b {
27
+ color: rgba(0, 196, 255, 0.5);
23
28
  }
24
29
  ```
25
30
 
@@ -38,21 +43,26 @@ const postcss = require('postcss');
38
43
  const postcssHWBFunction = require('@csstools/postcss-hwb-function');
39
44
 
40
45
  postcss([
41
- postcssHWBFunction(/* pluginOptions */)
46
+ postcssHWBFunction(/* pluginOptions */)
42
47
  ]).process(YOUR_CSS /*, processOptions */);
43
48
  ```
44
49
 
45
50
  [PostCSS HWB Function] runs in all Node environments, with special
46
51
  instructions for:
47
52
 
48
- | [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
49
- | --- | --- | --- | --- | --- |
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)
50
60
 
51
61
  ## Options
52
62
 
53
63
  ### preserve
54
64
 
55
- The `preserve` option determines whether the original functional color notation
65
+ The `preserve` option determines whether the original notation
56
66
  is preserved. By default, it is not preserved.
57
67
 
58
68
  ```js
@@ -62,15 +72,21 @@ postcssHWBFunction({ preserve: true })
62
72
  ```pcss
63
73
  a {
64
74
  color: hwb(194 0% 0%);
75
+ }
76
+
77
+ b {
65
78
  color: hwb(194 0% 0% / .5);
66
79
  }
67
80
 
68
81
  /* becomes */
69
82
 
70
83
  a {
71
- color: rgb(0, 195, 255);
84
+ color: rgb(0, 196, 255);
72
85
  color: hwb(194 0% 0%);
73
- color: rgba(0, 195, 255, .5);
86
+ }
87
+
88
+ b {
89
+ color: rgba(0, 196, 255, 0.5);
74
90
  color: hwb(194 0% 0% / .5);
75
91
  }
76
92
  ```
@@ -80,9 +96,6 @@ a {
80
96
  [discord]: https://discord.gg/bUadyRwkJS
81
97
  [npm-url]: https://www.npmjs.com/package/@csstools/postcss-hwb-function
82
98
 
83
- [CSS Color]: https://drafts.csswg.org/css-color/#the-hwb-notation
84
- [Gulp PostCSS]: https://github.com/postcss/gulp-postcss
85
- [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
86
99
  [PostCSS]: https://github.com/postcss/postcss
87
- [PostCSS Loader]: https://github.com/postcss/postcss-loader
88
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,n=/^hwb$/i,postcssPlugin=a=>{const l="preserve"in Object(a)&&Boolean(a?.preserve);return{postcssPlugin:"postcss-hwb-function",Declaration:(a,{postcss:p})=>{const c=a.value;if(!o.test(c))return;if(l&&hasSupportsAtRuleAncestor(a))return;if(hasFallback(a))return;const u=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(r.tokenize({css:c})),(r=>{if(t.isFunctionNode(r)&&n.test(r.getName())){const t=e.color(r);if(!t)return;if(t.syntaxFlags.has(e.SyntaxFlag.Experimental))return;if(t.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords))return;if(t.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax))return;return e.serializeRGB(t)}})),i=t.stringify(u);if(i!==c)if(a.variable&&l&&a.parent){const e=a.parent,t=p.atRule({name:"supports",params:s,source:a.source}),r=e.clone();r.removeAll(),r.append(a.clone()),t.append(r),insertAtSupportsAfterCorrectRule(t,e,s),a.replaceWith(a.clone({value:i}))}else l?a.cloneBefore({value:i}):a.replaceWith(a.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())){const o=e(s);if(!o)return;if(o.syntaxFlags.has(t.Experimental))return;if(o.syntaxFlags.has(t.HasNoneKeywords))return;if(o.syntaxFlags.has(t.RelativeColorSyntax))return;return r(o)}})),w=a(v);if(w!==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:w}))}else f?i.cloneBefore({value:w}):i.replaceWith(i.clone({value:w}))}}};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.7",
5
- "author": "Jonathan Neal <jonathantneal@hotmail.com>",
4
+ "version": "3.0.9",
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.0",
43
- "@csstools/css-parser-algorithms": "^2.4.0",
44
- "@csstools/css-tokenizer": "^2.2.2"
51
+ "@csstools/css-color-parser": "^1.5.2",
52
+ "@csstools/css-parser-algorithms": "^2.6.0",
53
+ "@csstools/css-tokenizer": "^2.2.3",
54
+ "@csstools/postcss-progressive-custom-properties": "^3.1.0",
55
+ "@csstools/utilities": "^1.0.0"
45
56
  },
46
57
  "peerDependencies": {
47
58
  "postcss": "^8.4"
@@ -55,19 +66,12 @@
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