Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Update to PostCSS 8 #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Node.js CI

on: [ push, pull_request ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
22 changes: 9 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
var postcss = require('postcss');

module.exports = postcss.plugin('pseudoelements', (options) => {

options = options || { single: true };

var selectors = options.selectors || [
module.exports = (options = { single: true }) => {
const selectors = options.selectors || [
'before',
'after',
'first-letter',
'first-line'
]

var replacements = new RegExp(':{1,}(' + selectors.join('|') + ')', 'gi');
var replaceWith = options.single ? ':$1' : '::$1'
const replacements = new RegExp(':{1,}(' + selectors.join('|') + ')', 'gi');
const replaceWith = options.single ? ':$1' : '::$1'

return (css) => {
css.walkRules((rule) => {
return {
postcssPlugin: 'pseudoelements',
Rule(rule) {
rule.selector = rule.selector.replace(replacements, replaceWith);
});
}
};
});
};
Loading