-
If you have problems with the output CSS from Autoprefixer; you’ll need to post:
- Input CSS.
- Output CSS.
- Expected output CSS.
- Browserslist config. If you use
browsers
or option, create Browserslist config first. - Run
npm ls | grep autoprefixer
and check output.
-
If Autoprefixer throws error:
- Input CSS.
- Browserslist config.
- Error stacktrace (copy and paste the error message that you get so we can identify where the problem is).
- Run
npm ls | grep autoprefixer
and check output. - Run
npm ls | grep postcss
and check output.
Before you begin contributing make sure you have a GitHub account.
- Fork the repository
- Clone a copy of it to your computer:
git clone https://github.com/USERNAME/autoprefixer
(replaceUSERNAME
to your GitHub name). - Ensure that you have the pnpm package manager installed.
- Run
pnpm install
this will install all dependencies needed to run tests.
We’ll explain how would you go about adding a CSS feature to Autoprefixer.
For example, we’ll add support for a CSS feature called background-clip: text
.
Note: Remember that the feature that you want to add must also be supported on Can I use.
-
Create a topic branch from the
master
branch. Like this:git checkout -b background-clip-text
. -
To add support for a CSS feature you must call the convert function inside of
data/prefixes.js
and specify three parameters: data, options and a callback. Like this:f(require('caniuse-lite/data/features/background-clip-text'), browsers => prefix(['background-clip'], { feature: 'background-clip-text', browsers }) )
-
If the prefix is simple (
-webkit-
for Safari,-moz-
for Firefox, all use the same syntax) go to step 8. -
If you need some non-standard behavior for the prefix (
-webkit-
prefix for Firefox or different syntax for different browsers) you will need to create a “hack”. Create a JS file in thelibs/hacks
folder using the name of the CSS feature as the filename. -
Check out other hacks for examples. In this new class change the prefix for
IE
to-webkit-
. See complete example -
Load the new hack in
lib/prefixes.js
. Load it intoDeclaration
if you need a prefix for property name. Load it intoValue
if you need a prefix for value.Declaration.hack(require('./hacks/background-clip'))
-
Create a
.css
and.out.css
example intest/cases
. Add this test totest/autoprefixer.test.js
:it('supports background-clip', () => check('background-clip'))
If you need different browsers, change
prefixer()
function in the top of test file. -
Run
pnpm test
. -
Push the branch to GitHub.
-
Open your fork on GitHub an send pull request.