Skip to content

Commit

Permalink
Update dependencies and practies
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Oct 8, 2023
1 parent ebd0ba1 commit bd604b2
Show file tree
Hide file tree
Showing 6 changed files with 1,207 additions and 833 deletions.
27 changes: 23 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest
version: 8
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 19
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest
version: 8
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand All @@ -51,3 +51,22 @@ jobs:
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Run unit tests
run: pnpm unit
short:
runs-on: ubuntu-latest
name: Node.js 14 Quick
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7
- name: Install Node.js 14
uses: actions/setup-node@v3
with:
node-version: 14
cache: pnpm
- name: Install dependencies
run: pnpm install --no-frozen-lockfile --ignore-scripts
- name: Run unit tests
run: pnpm unit
31 changes: 18 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
"url": "https://github.com/ai/webp-in-css/issues"
},
"scripts": {
"unit": "uvu . '\\.test\\.(ts|js)$'",
"test": "c8 yarn unit && eslint . && size-limit"
"unit": "uvu . '\\.test\\.js$'",
"test:coverage": "c8 pnpm unit",
"test:lint": "eslint .",
"test:size": "size-limit",
"test": "pnpm run /^test:/"
},
"engines": {
"node": ">=14.0"
Expand All @@ -27,25 +30,27 @@
"url": "https://opencollective.com/postcss/"
},
"dependencies": {
"postcss-selector-parser": "^6.0.11"
"postcss-selector-parser": "^6.0.13"
},
"peerDependencies": {
"postcss": "^8.2.14"
},
"devDependencies": {
"@logux/eslint-config": "^48.0.0",
"@size-limit/preset-small-lib": "^8.1.0",
"c8": "^7.12.0",
"clean-publish": "^4.0.2",
"eslint": "^8.30.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.6.0",
"@logux/eslint-config": "^52.0.1",
"@size-limit/preset-small-lib": "^9.0.0",
"c8": "^8.0.1",
"clean-publish": "^4.2.0",
"eslint": "^8.51.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-n": "^16.1.0",
"eslint-plugin-node-import": "^1.0.4",
"eslint-plugin-perfectionist": "^2.1.0",
"eslint-plugin-prefer-let": "^3.0.1",
"eslint-plugin-promise": "^6.1.1",
"nanodelay": "^1.0.8",
"postcss": "^8.4.20",
"size-limit": "^8.1.0",
"postcss": "^8.4.31",
"size-limit": "^9.0.0",
"uvu": "^0.5.6"
},
"size-limit": [
Expand Down
16 changes: 8 additions & 8 deletions plugin.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const selectorParser = require('postcss-selector-parser');

const DEFAULT_OPTIONS = {
modules: false,
noWebpClass: 'no-webp',
webpClass: 'webp',
addNoJs: true,
noJsClass: 'no-js',
check: decl =>
/\.(jpe?g|png)(?!(\.webp|.*[&?]format=webp))/i.test(decl.value),
rename: oldName => oldName.replace(/\.(jpe?g|png)/gi, '.webp')
modules: false,
noJsClass: 'no-js',
noWebpClass: 'no-webp',
rename: oldName => oldName.replace(/\.(jpe?g|png)/gi, '.webp'),
webpClass: 'webp'
}

module.exports = (opts = {}) => {
let { modules, noWebpClass, webpClass, addNoJs, noJsClass, rename, check } = {
let { addNoJs, check, modules, noJsClass, noWebpClass, rename, webpClass } = {
...DEFAULT_OPTIONS,
...opts
}
Expand Down Expand Up @@ -131,7 +131,6 @@ module.exports = (opts = {}) => {
}

return {
postcssPlugin: 'webp-in-css/plugin',
Declaration(decl) {
if (check(decl)) {
let rule = decl.parent
Expand Down Expand Up @@ -165,7 +164,8 @@ module.exports = (opts = {}) => {
i.prop = 'background-image'
})
}
}
},
postcssPlugin: 'webp-in-css/plugin'
}
}
module.exports.postcss = true
Loading

0 comments on commit bd604b2

Please sign in to comment.