@zaininnari/postcss-cachebuster 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -4
- package/LICENSE +1 -0
- package/README.md +43 -31
- package/eslint.config.js +22 -18
- package/index.mjs +4 -5
- package/package.json +6 -2
- package/.github/workflows/lint.yml +0 -28
- package/.github/workflows/test-latest.yml +0 -31
- package/.github/workflows/test.yml +0 -28
- package/.idea/copilot.data.migration.ask2agent.xml +0 -6
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0 (2026-01-04)
|
|
4
|
+
|
|
5
|
+
- Add Prettier
|
|
6
|
+
|
|
3
7
|
## 0.4.1 (2026-01-02)
|
|
8
|
+
|
|
4
9
|
- Add ESLint
|
|
5
10
|
- @eslint/js recommended
|
|
6
11
|
- eslint-plugin-n recommended
|
|
7
12
|
|
|
8
13
|
## 0.4.0 (2025-12-30)
|
|
14
|
+
|
|
9
15
|
- update dependencies
|
|
10
16
|
- update support node version 20+
|
|
11
17
|
|
|
12
18
|
## 0.3.0 (2025-12-29)
|
|
19
|
+
|
|
13
20
|
- update npm package
|
|
14
21
|
- update support node version 18+
|
|
15
22
|
|
|
@@ -20,12 +27,13 @@
|
|
|
20
27
|
## 0.1.5 (2018-12-07)
|
|
21
28
|
|
|
22
29
|
## 0.1.4 (2017-01-07)
|
|
30
|
+
|
|
23
31
|
Fix multiple css imports in single css file.
|
|
24
32
|
|
|
25
33
|
## 0.1.3 (2016-05-27)
|
|
26
34
|
|
|
27
|
-
- `type` can be defined as function.
|
|
28
|
-
Thanks for Jackson Ray Hamilton [@jacksonrayhamilton](http://github.com/jacksonrayhamilton)
|
|
35
|
+
- `type` can be defined as function.
|
|
36
|
+
Thanks for Jackson Ray Hamilton [@jacksonrayhamilton](http://github.com/jacksonrayhamilton)
|
|
29
37
|
|
|
30
38
|
## 0.1.2 (2015-11-19)
|
|
31
39
|
|
|
@@ -34,5 +42,3 @@ Thanks for Jackson Ray Hamilton [@jacksonrayhamilton](http://github.com/jacksonr
|
|
|
34
42
|
## 0.1.1 (2015-11-18)
|
|
35
43
|
|
|
36
44
|
- Added .htc support
|
|
37
|
-
|
|
38
|
-
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
3
|
Copyright 2015 Gleb Mikheev <glebmachine@gmail.com>
|
|
4
|
+
Copyright 2026 zaininnari
|
|
4
5
|
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
7
|
this software and associated documentation files (the "Software"), to deal in
|
package/README.md
CHANGED
|
@@ -8,29 +8,34 @@ This project is a fork of https://github.com/glebmachine/postcss-cachebuster.
|
|
|
8
8
|
[PostCSS] plugin added cachebuster to local files based on their date changed.
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
|
+
|
|
11
12
|
```bash
|
|
12
13
|
npm i -D @zaininnari/postcss-cachebuster
|
|
13
14
|
```
|
|
14
15
|
|
|
15
16
|
## Usage
|
|
17
|
+
|
|
16
18
|
```js
|
|
17
19
|
import postcss from 'postcss';
|
|
18
20
|
import cachebuster from '@zaininnari/postcss-cachebuster';
|
|
19
21
|
|
|
20
|
-
await postcss([
|
|
22
|
+
const result = await postcss([
|
|
21
23
|
cachebuster({
|
|
22
24
|
imagesPath: '/images',
|
|
23
|
-
cssPath: '/stylesheets'
|
|
24
|
-
})
|
|
25
|
+
cssPath: '/stylesheets',
|
|
26
|
+
}),
|
|
25
27
|
]).process(css, { from: undefined });
|
|
28
|
+
|
|
29
|
+
result.css;
|
|
26
30
|
```
|
|
27
31
|
|
|
28
32
|
## Input css example
|
|
33
|
+
|
|
29
34
|
```css
|
|
30
|
-
@import url(
|
|
35
|
+
@import url('/css/styles.css');
|
|
31
36
|
.foo {
|
|
32
|
-
background-image
|
|
33
|
-
behavior
|
|
37
|
+
background-image: url('../images/index/logo.png');
|
|
38
|
+
behavior: url('../behaviors/backgroundsize.min.htc');
|
|
34
39
|
}
|
|
35
40
|
@font-face {
|
|
36
41
|
font-family: 'My font';
|
|
@@ -39,11 +44,12 @@ await postcss([
|
|
|
39
44
|
```
|
|
40
45
|
|
|
41
46
|
## Output css example
|
|
47
|
+
|
|
42
48
|
```css
|
|
43
|
-
@import url(
|
|
49
|
+
@import url('/css/styles.css?v66f22a33fff');
|
|
44
50
|
.foo {
|
|
45
|
-
background-image
|
|
46
|
-
behavior
|
|
51
|
+
background-image: url('../images/index/logo.png?v14f32a475b8');
|
|
52
|
+
behavior: url('../behaviors/backgroundsize.min.htc?v15f55a666c2');
|
|
47
53
|
}
|
|
48
54
|
@font-face {
|
|
49
55
|
font-family: 'My font';
|
|
@@ -52,14 +58,19 @@ await postcss([
|
|
|
52
58
|
```
|
|
53
59
|
|
|
54
60
|
## Configure
|
|
61
|
+
|
|
55
62
|
```js
|
|
56
|
-
postcss
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
import postcss from 'postcss';
|
|
64
|
+
import cachebuster from '@zaininnari/postcss-cachebuster';
|
|
65
|
+
|
|
66
|
+
postcss([
|
|
67
|
+
cachebuster({
|
|
68
|
+
imagesPath: '/images',
|
|
69
|
+
cssPath: '/stylesheets',
|
|
70
|
+
}),
|
|
71
|
+
]);
|
|
62
72
|
```
|
|
73
|
+
|
|
63
74
|
See [PostCSS] docs for examples for your environment.
|
|
64
75
|
|
|
65
76
|
[PostCSS]: https://postcss.org/
|
|
@@ -95,31 +106,32 @@ Add to this list by setting the `additionalProps` configuration option.
|
|
|
95
106
|
To add support for `mask-image` properties, for example:
|
|
96
107
|
|
|
97
108
|
```js
|
|
98
|
-
postcss
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
]
|
|
104
|
-
})
|
|
105
|
-
])
|
|
109
|
+
import postcss from 'postcss';
|
|
110
|
+
import cachebuster from '@zaininnari/postcss-cachebuster';
|
|
111
|
+
|
|
112
|
+
postcss([
|
|
113
|
+
cachebuster({
|
|
114
|
+
additionalProps: ['mask-image', '-webkit-mask-image'],
|
|
115
|
+
}),
|
|
116
|
+
]);
|
|
106
117
|
```
|
|
107
118
|
|
|
108
119
|
Replace the default list by setting the `supportedProps` configuration option.
|
|
109
120
|
To limit the cachbusting to background images only, for example:
|
|
110
121
|
|
|
111
122
|
```js
|
|
112
|
-
postcss
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
]
|
|
118
|
-
})
|
|
119
|
-
])
|
|
123
|
+
import postcss from 'postcss';
|
|
124
|
+
import cachebuster from '@zaininnari/postcss-cachebuster';
|
|
125
|
+
|
|
126
|
+
postcss([
|
|
127
|
+
cachebuster({
|
|
128
|
+
supportedProps: ['background', 'background-image'],
|
|
129
|
+
}),
|
|
130
|
+
]);
|
|
120
131
|
```
|
|
121
132
|
|
|
122
133
|
## Contributors
|
|
134
|
+
|
|
123
135
|
- Gleb Mikheev (https://github.com/glebmachine)
|
|
124
136
|
- Graham Bates (https://github.com/grahambates)
|
|
125
137
|
- Yusuke Yagyu (https://github.com/gyugyu)
|
package/eslint.config.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import js from
|
|
2
|
-
import globals from
|
|
3
|
-
import n from
|
|
4
|
-
import
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
import n from 'eslint-plugin-n';
|
|
4
|
+
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
5
|
+
import { defineConfig } from 'eslint/config';
|
|
5
6
|
|
|
6
7
|
export default defineConfig([
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
plugins: {js, n},
|
|
19
|
-
extends: ["js/recommended", "n/recommended"],
|
|
20
|
-
ignores: ['eslint.config.js'],
|
|
8
|
+
{
|
|
9
|
+
files: ['**/*.{js,mjs,cjs}'],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
ecmaVersion: 'latest',
|
|
12
|
+
sourceType: 'module',
|
|
13
|
+
globals: {
|
|
14
|
+
...globals.node,
|
|
15
|
+
...globals.mocha,
|
|
16
|
+
myCustomGlobal: 'readonly',
|
|
17
|
+
},
|
|
21
18
|
},
|
|
19
|
+
plugins: {
|
|
20
|
+
js,
|
|
21
|
+
n,
|
|
22
|
+
},
|
|
23
|
+
extends: ['js/recommended', 'n/recommended', eslintConfigPrettier],
|
|
24
|
+
ignores: ['eslint.config.js'],
|
|
25
|
+
},
|
|
22
26
|
]);
|
package/index.mjs
CHANGED
|
@@ -17,6 +17,7 @@ const checksums = {};
|
|
|
17
17
|
|
|
18
18
|
const plugin = (opts = {}) => {
|
|
19
19
|
const pattern = /url\((['"])?([^'")]+)(['"])?\)/g;
|
|
20
|
+
// prettier-ignore
|
|
20
21
|
const supportedPropsDefault = [
|
|
21
22
|
'background',
|
|
22
23
|
'background-image',
|
|
@@ -50,9 +51,7 @@ const plugin = (opts = {}) => {
|
|
|
50
51
|
cachebuster = checksums[checksumKey];
|
|
51
52
|
} else {
|
|
52
53
|
const data = fs.readFileSync(assetPath);
|
|
53
|
-
cachebuster = crypto.createHash(opts.hashAlgorithm)
|
|
54
|
-
.update(data)
|
|
55
|
-
.digest('hex');
|
|
54
|
+
cachebuster = crypto.createHash(opts.hashAlgorithm).update(data).digest('hex');
|
|
56
55
|
|
|
57
56
|
checksums[checksumKey] = cachebuster;
|
|
58
57
|
}
|
|
@@ -116,7 +115,7 @@ const plugin = (opts = {}) => {
|
|
|
116
115
|
const isAbsolute = /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(input);
|
|
117
116
|
const isRootRelativeButNotProtocolRelative = /^\/(?!\/)/.test(input);
|
|
118
117
|
const u = isAbsolute ? new URL(input) : new URL(input, DUMMY_BASE);
|
|
119
|
-
return {u, isAbsolute, isRootRelativeButNotProtocolRelative, originalUrl: input};
|
|
118
|
+
return { u, isAbsolute, isRootRelativeButNotProtocolRelative, originalUrl: input };
|
|
120
119
|
}
|
|
121
120
|
|
|
122
121
|
/**
|
|
@@ -134,7 +133,7 @@ const plugin = (opts = {}) => {
|
|
|
134
133
|
const url = `${u.pathname}${u.search}${u.hash}`;
|
|
135
134
|
if (!isRootRelativeButNotProtocolRelative) {
|
|
136
135
|
// remove start slash
|
|
137
|
-
return
|
|
136
|
+
return url.substring(1);
|
|
138
137
|
}
|
|
139
138
|
return url;
|
|
140
139
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zaininnari/postcss-cachebuster",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Fork of postcss-cachebuster. Cachebusting all local files in css",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postcss",
|
|
@@ -41,12 +41,14 @@
|
|
|
41
41
|
"@eslint/js": "^9.39.2",
|
|
42
42
|
"chai": "^6.2.2",
|
|
43
43
|
"eslint": "^9.39.2",
|
|
44
|
+
"eslint-config-prettier": "^10.1.8",
|
|
44
45
|
"eslint-plugin-n": "^17.23.1",
|
|
45
46
|
"globals": "^16.5.0",
|
|
46
47
|
"gulp": "^5.0.1",
|
|
47
48
|
"gulp-mocha": "^10.0.1",
|
|
48
49
|
"gulp-postcss": "^10.0.0",
|
|
49
50
|
"postcss": "^8.5.6",
|
|
51
|
+
"prettier": "^3.7.4",
|
|
50
52
|
"sinon": "^21.0.1",
|
|
51
53
|
"sinon-chai": "^4.0.1"
|
|
52
54
|
},
|
|
@@ -55,6 +57,8 @@
|
|
|
55
57
|
},
|
|
56
58
|
"scripts": {
|
|
57
59
|
"lint": "eslint .",
|
|
58
|
-
"test": "gulp --gulpfile gulpfile.mjs"
|
|
60
|
+
"test": "gulp --gulpfile gulpfile.mjs",
|
|
61
|
+
"format:check": "prettier . --check",
|
|
62
|
+
"format:write": "prettier . --write"
|
|
59
63
|
}
|
|
60
64
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
name: Lint
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
pull_request:
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
test:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
|
|
11
|
-
strategy:
|
|
12
|
-
matrix:
|
|
13
|
-
node-version: [20, 22, 24]
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v4
|
|
17
|
-
|
|
18
|
-
- name: Use Node.js
|
|
19
|
-
uses: actions/setup-node@v4
|
|
20
|
-
with:
|
|
21
|
-
node-version: ${{ matrix.node-version }}
|
|
22
|
-
cache: 'npm'
|
|
23
|
-
|
|
24
|
-
- name: Install dependencies
|
|
25
|
-
run: npm ci
|
|
26
|
-
|
|
27
|
-
- name: Run tests
|
|
28
|
-
run: npm run lint
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
name: Test (latest deps)
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
pull_request:
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
test:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
|
|
11
|
-
strategy:
|
|
12
|
-
matrix:
|
|
13
|
-
node-version: [20, 22, 24]
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v4
|
|
17
|
-
|
|
18
|
-
- name: Use Node.js
|
|
19
|
-
uses: actions/setup-node@v4
|
|
20
|
-
with:
|
|
21
|
-
node-version: ${{ matrix.node-version }}
|
|
22
|
-
|
|
23
|
-
- name: Remove package-lock.json
|
|
24
|
-
run: rm -f package-lock.json
|
|
25
|
-
|
|
26
|
-
- name: Install dependencies (latest allowed by package.json)
|
|
27
|
-
run: npm install
|
|
28
|
-
|
|
29
|
-
- name: Run tests
|
|
30
|
-
run: npm test
|
|
31
|
-
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
name: Test
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
pull_request:
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
test:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
|
|
11
|
-
strategy:
|
|
12
|
-
matrix:
|
|
13
|
-
node-version: [20, 22, 24]
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v4
|
|
17
|
-
|
|
18
|
-
- name: Use Node.js
|
|
19
|
-
uses: actions/setup-node@v4
|
|
20
|
-
with:
|
|
21
|
-
node-version: ${{ matrix.node-version }}
|
|
22
|
-
cache: 'npm'
|
|
23
|
-
|
|
24
|
-
- name: Install dependencies
|
|
25
|
-
run: npm ci
|
|
26
|
-
|
|
27
|
-
- name: Run tests
|
|
28
|
-
run: npm test
|
package/.idea/misc.xml
DELETED
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/postcss-cachebuster.iml" filepath="$PROJECT_DIR$/postcss-cachebuster.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|