source: frontend/node_modules/@csstools/postcss-hwb-function/INSTALL.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 3.7 KB
Line 
1# Installing PostCSS HWB Function
2
3[PostCSS HWB Function] runs in all Node environments, with special instructions for:
4
5| [Node](#node) | [PostCSS CLI](#postcss-cli) | [Webpack](#webpack) | [Create React App](#create-react-app) | [Gulp](#gulp) | [Grunt](#grunt) |
6| --- | --- | --- | --- | --- | --- |
7
8## Node
9
10Add [PostCSS HWB Function] to your project:
11
12```bash
13npm install postcss @csstools/postcss-hwb-function --save-dev
14```
15
16Use it as a [PostCSS] plugin:
17
18```js
19const postcss = require('postcss');
20const postcssHWBFunction = require('@csstools/postcss-hwb-function');
21
22postcss([
23 postcssHWBFunction(/* pluginOptions */)
24]).process(YOUR_CSS /*, processOptions */);
25```
26
27## PostCSS CLI
28
29Add [PostCSS CLI] to your project:
30
31```bash
32npm install postcss-cli @csstools/postcss-hwb-function --save-dev
33```
34
35Use [PostCSS HWB Function] in your `postcss.config.js` configuration file:
36
37```js
38const postcssHWBFunction = require('@csstools/postcss-hwb-function');
39
40module.exports = {
41 plugins: [
42 postcssHWBFunction(/* pluginOptions */)
43 ]
44}
45```
46
47## Webpack
48
49_Webpack version 5_
50
51Add [PostCSS Loader] to your project:
52
53```bash
54npm install postcss-loader @csstools/postcss-hwb-function --save-dev
55```
56
57Use [PostCSS HWB Function] in your Webpack configuration:
58
59```js
60module.exports = {
61 module: {
62 rules: [
63 {
64 test: /\.css$/i,
65 use: [
66 "style-loader",
67 {
68 loader: "css-loader",
69 options: { importLoaders: 1 },
70 },
71 {
72 loader: "postcss-loader",
73 options: {
74 postcssOptions: {
75 plugins: [
76 [
77 "@csstools/postcss-hwb-function",
78 {
79 // Options
80 },
81 ],
82 ],
83 },
84 },
85 },
86 ],
87 },
88 ],
89 },
90};
91```
92
93## Create React App
94
95Add [React App Rewired] and [React App Rewire PostCSS] to your project:
96
97```bash
98npm install react-app-rewired react-app-rewire-postcss @csstools/postcss-hwb-function --save-dev
99```
100
101Use [React App Rewire PostCSS] and [PostCSS HWB Function] in your
102`config-overrides.js` file:
103
104```js
105const reactAppRewirePostcss = require('react-app-rewire-postcss');
106const postcssHWBFunction = require('@csstools/postcss-hwb-function');
107
108module.exports = config => reactAppRewirePostcss(config, {
109 plugins: () => [
110 postcssHWBFunction(/* pluginOptions */)
111 ]
112});
113```
114
115## Gulp
116
117Add [Gulp PostCSS] to your project:
118
119```bash
120npm install gulp-postcss @csstools/postcss-hwb-function --save-dev
121```
122
123Use [PostCSS HWB Function] in your Gulpfile:
124
125```js
126const postcss = require('gulp-postcss');
127const postcssHWBFunction = require('@csstools/postcss-hwb-function');
128
129gulp.task('css', function () {
130 var plugins = [
131 postcssHWBFunction(/* pluginOptions */)
132 ];
133
134 return gulp.src('./src/*.css')
135 .pipe(postcss(plugins))
136 .pipe(gulp.dest('.'));
137});
138```
139
140## Grunt
141
142Add [Grunt PostCSS] to your project:
143
144```bash
145npm install grunt-postcss @csstools/postcss-hwb-function --save-dev
146```
147
148Use [PostCSS HWB Function] in your Gruntfile:
149
150```js
151const postcssHWBFunction = require('@csstools/postcss-hwb-function');
152
153grunt.loadNpmTasks('grunt-postcss');
154
155grunt.initConfig({
156 postcss: {
157 options: {
158 processors: [
159 postcssHWBFunction(/* pluginOptions */)
160 ]
161 },
162 dist: {
163 src: '*.css'
164 }
165 }
166});
167```
168
169[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
170[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
171[PostCSS]: https://github.com/postcss/postcss
172[PostCSS CLI]: https://github.com/postcss/postcss-cli
173[PostCSS Loader]: https://github.com/postcss/postcss-loader
174[PostCSS HWB Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-hwb-function
175[React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss
176[React App Rewired]: https://github.com/timarney/react-app-rewired
Note: See TracBrowser for help on using the repository browser.