Skip to content

Commit

Permalink
Merge pull request #33 from hudochenkov/migrate-to-postcss-8
Browse files Browse the repository at this point in the history
  • Loading branch information
madeleineostoja authored Jul 10, 2022
2 parents 7b119ed + 17522c4 commit dceefe3
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sudo: false
language: node_js
node_js:
- "14"
- "12"
- "10"
- "8"
- "6"
17 changes: 10 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const postcss = require('postcss');
const valueParser = require('postcss-value-parser');

const rgbShorthandRegex = /^([a-f\d])([a-f\d])([a-f\d])$/i;
Expand Down Expand Up @@ -58,14 +57,18 @@ function ruleHandler(decl, result) {
decl.value = value;
}

module.exports = postcss.plugin('postcss-hexrgba', () => {
return (css, result) => {
css.walkDecls(decl => {
if (decl.value.indexOf('rgba') === -1) {
module.exports = () => {
return {
postcssPlugin: 'postcss-hexrgba',

Declaration(decl, { result }) {
if (!decl.value.includes('rgba')) {
return;
}

ruleHandler(decl, result);
});
},
};
});
};

module.exports.postcss = true;
77 changes: 58 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
}
],
"dependencies": {
"postcss": "^7.0.14",
"postcss-value-parser": "^4.1.0"
},
"peerDependencies": {
"postcss": "^8.1.4"
},
"devDependencies": {
"chai": "^4.2.0",
"eslint": "^5.16.0",
"mocha": "^6.1.1"
"mocha": "^6.1.1",
"postcss": "^8.1.4"
},
"scripts": {
"test": "mocha test",
Expand Down

0 comments on commit dceefe3

Please sign in to comment.