Debian Codegraph @

autoprefixer/.github/CONTRIBUTING.md

raw symbols SCIP
1 <img width="94" height="71" src="../logo.svg" title="Autoprefixer logo by Anton Lovchikov">
2
3 # Contributing to Autoprefixer
4
5 * [Filing Issues](#filing-issues)
6 * [Getting Started](#getting-started)
7 * [Adding a Prefix](#adding-a-prefix)
8
9
10 ## Filing Issues
11
12 - If you have problems with the output CSS from Autoprefixer;
13 you’ll need to post:
14
15 1. Input CSS.
16 2. Output CSS.
17 3. Expected output CSS.
18 4. Browserslist config. If you use `browsers` or option,
19 create Browserslist config first.
20 5. Run `npm ls | grep autoprefixer` and check output.
21
22 - If Autoprefixer throws error:
23
24 1. Input CSS.
25 2. Browserslist config.
26 3. Error stacktrace (copy and paste the error message that you get
27 so we can identify where the problem is).
28 4. Run `npm ls | grep autoprefixer` and check output.
29 5. Run `npm ls | grep postcss` and check output.
30
31
32 ## Getting Started
33
34 Before you begin contributing make sure you have a [GitHub account].
35
36 * [Fork the repository](https://github.com/postcss/autoprefixer)
37 * Clone a copy of it to your computer:
38 `git clone https://github.com/USERNAME/autoprefixer` (replace `USERNAME`
39 to your GitHub name).
40 * Ensure that you have the [pnpm](https://pnpm.io/) package manager
41 installed.
42 * Run `pnpm install` this will install all dependencies needed to run tests.
43
44 [GitHub account]: https://github.com/signup/free
45
46
47 ## Adding a Prefix
48
49 We’ll explain how would you go about adding a CSS feature to Autoprefixer.
50 For example, we’ll add support for a CSS feature called `background-clip: text`.
51
52 Note: Remember that the feature that you want to add must also be supported
53 on [Can I use](https://caniuse.com/).
54
55 1. Create a topic branch from the `master` branch.
56 Like this: `git checkout -b background-clip-text`.
57
58 2. To add support for a CSS feature you must call the convert function inside
59 of `data/prefixes.js` and specify three parameters: data, options
60 and a callback. Like this:
61
62 ```js
63 f(require('caniuse-lite/data/features/background-clip-text'), browsers =>
64 prefix(['background-clip'], {
65 feature: 'background-clip-text',
66 browsers
67 })
68 )
69 ```
70
71 3. If the prefix is simple (`-webkit-` for Safari, `-moz-` for Firefox,
72 all use the same syntax) go to step 8.
73
74 4. If you need some non-standard behavior for the prefix (`-webkit-` prefix
75 for Firefox or different syntax for different browsers) you will need
76 to create a “hack”. Create a JS file in the `libs/hacks` folder using
77 the name of the CSS feature as the filename.
78
79 5. Check out other hacks for examples. In this new class change the prefix
80 for `IE` to `-webkit-`. [See complete example](https://github.com/postcss/Autoprefixer/blob/73c7b6ab090a9a9a03869b3099096af00be7eb7d/lib/hacks/background-clip.js)
81
82 6. Load the new hack in `lib/prefixes.js`. Load it into `Declaration`
83 if you need a prefix for property name. Load it into `Value` if you need
84 a prefix for value.
85
86 ```js
87 Declaration.hack(require('./hacks/background-clip'))
88 ```
89
90 7. Create a `.css` and `.out.css` example in `test/cases`. Add this test to
91 `test/autoprefixer.test.js`:
92
93 ```js
94 it('supports background-clip', () => check('background-clip'))
95 ```
96
97 If you need different browsers, change `prefixer()` function in the top
98 of test file.
99
100 8. Run `pnpm test`.
101 9. Push the branch to GitHub.
102 10. Open your fork on GitHub an send pull request.