@csstools/postcss-hwb-function 3.0.8 → 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 +9 -6
- package/README.md +33 -21
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.mjs +1 -1
- package/package.json +17 -13
- package/INSTALL.md +0 -235
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changes to PostCSS HWB Function
|
|
2
2
|
|
|
3
|
+
### 3.0.9
|
|
4
|
+
|
|
5
|
+
_February 19, 2024_
|
|
6
|
+
|
|
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
|
+
|
|
3
12
|
### 3.0.8
|
|
4
13
|
|
|
5
14
|
_December 31, 2023_
|
|
@@ -17,10 +26,4 @@ _December 15, 2023_
|
|
|
17
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)
|
|
18
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)
|
|
19
28
|
|
|
20
|
-
### 3.0.6
|
|
21
|
-
|
|
22
|
-
_October 9, 2023_
|
|
23
|
-
|
|
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
|
-
|
|
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">][
|
|
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
|
-
|
|
11
|
-
|
|
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,
|
|
23
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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,
|
|
84
|
+
color: rgb(0, 196, 255);
|
|
73
85
|
color: hwb(194 0% 0%);
|
|
74
|
-
|
|
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"),
|
|
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
|
|
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.
|
|
5
|
-
"
|
|
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.
|
|
43
|
-
"@csstools/css-parser-algorithms": "^2.
|
|
44
|
-
"@csstools/css-tokenizer": "^2.2.3"
|
|
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
|