@zaininnari/postcss-cachebuster 0.4.1 → 0.6.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 +14 -4
- package/LICENSE +1 -0
- package/README.md +43 -31
- package/index.mjs +10 -8
- package/package.json +7 -5
- 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/eslint.config.js +0 -22
- package/postcss-cachebuster.iml +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0 (2026-01-04)
|
|
4
|
+
|
|
5
|
+
- remove unnecessary canonical-path and path polyfill
|
|
6
|
+
|
|
7
|
+
## 0.5.0 (2026-01-04)
|
|
8
|
+
|
|
9
|
+
- Add Prettier
|
|
10
|
+
|
|
3
11
|
## 0.4.1 (2026-01-02)
|
|
12
|
+
|
|
4
13
|
- Add ESLint
|
|
5
14
|
- @eslint/js recommended
|
|
6
15
|
- eslint-plugin-n recommended
|
|
7
16
|
|
|
8
17
|
## 0.4.0 (2025-12-30)
|
|
18
|
+
|
|
9
19
|
- update dependencies
|
|
10
20
|
- update support node version 20+
|
|
11
21
|
|
|
12
22
|
## 0.3.0 (2025-12-29)
|
|
23
|
+
|
|
13
24
|
- update npm package
|
|
14
25
|
- update support node version 18+
|
|
15
26
|
|
|
@@ -20,12 +31,13 @@
|
|
|
20
31
|
## 0.1.5 (2018-12-07)
|
|
21
32
|
|
|
22
33
|
## 0.1.4 (2017-01-07)
|
|
34
|
+
|
|
23
35
|
Fix multiple css imports in single css file.
|
|
24
36
|
|
|
25
37
|
## 0.1.3 (2016-05-27)
|
|
26
38
|
|
|
27
|
-
- `type` can be defined as function.
|
|
28
|
-
Thanks for Jackson Ray Hamilton [@jacksonrayhamilton](http://github.com/jacksonrayhamilton)
|
|
39
|
+
- `type` can be defined as function.
|
|
40
|
+
Thanks for Jackson Ray Hamilton [@jacksonrayhamilton](http://github.com/jacksonrayhamilton)
|
|
29
41
|
|
|
30
42
|
## 0.1.2 (2015-11-19)
|
|
31
43
|
|
|
@@ -34,5 +46,3 @@ Thanks for Jackson Ray Hamilton [@jacksonrayhamilton](http://github.com/jacksonr
|
|
|
34
46
|
## 0.1.1 (2015-11-18)
|
|
35
47
|
|
|
36
48
|
- 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/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import crypto from 'crypto';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
|
|
5
|
-
import path from '
|
|
5
|
+
import path from 'node:path';
|
|
6
6
|
|
|
7
7
|
const checksums = {};
|
|
8
8
|
|
|
@@ -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
|
}
|
|
@@ -74,10 +73,13 @@ const plugin = (opts = {}) => {
|
|
|
74
73
|
function resolveUrl(assetUrl, file, imagesPath, isRootRelativeButNotProtocolRelative) {
|
|
75
74
|
let assetPath = decodeURI(assetUrl.pathname);
|
|
76
75
|
|
|
76
|
+
// URL pathname always use '/', so use the POSIX API here to avoid introducing OS-specific path separators.
|
|
77
|
+
const posixPath = path.posix;
|
|
78
|
+
|
|
77
79
|
if (isRootRelativeButNotProtocolRelative) {
|
|
78
|
-
assetPath =
|
|
80
|
+
assetPath = posixPath.join(imagesPath, assetPath);
|
|
79
81
|
} else {
|
|
80
|
-
assetPath =
|
|
82
|
+
assetPath = posixPath.join(opts.cssPath || posixPath.dirname(file), assetPath);
|
|
81
83
|
}
|
|
82
84
|
return assetPath;
|
|
83
85
|
}
|
|
@@ -116,7 +118,7 @@ const plugin = (opts = {}) => {
|
|
|
116
118
|
const isAbsolute = /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(input);
|
|
117
119
|
const isRootRelativeButNotProtocolRelative = /^\/(?!\/)/.test(input);
|
|
118
120
|
const u = isAbsolute ? new URL(input) : new URL(input, DUMMY_BASE);
|
|
119
|
-
return {u, isAbsolute, isRootRelativeButNotProtocolRelative, originalUrl: input};
|
|
121
|
+
return { u, isAbsolute, isRootRelativeButNotProtocolRelative, originalUrl: input };
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
/**
|
|
@@ -134,7 +136,7 @@ const plugin = (opts = {}) => {
|
|
|
134
136
|
const url = `${u.pathname}${u.search}${u.hash}`;
|
|
135
137
|
if (!isRootRelativeButNotProtocolRelative) {
|
|
136
138
|
// remove start slash
|
|
137
|
-
return
|
|
139
|
+
return url.substring(1);
|
|
138
140
|
}
|
|
139
141
|
return url;
|
|
140
142
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zaininnari/postcss-cachebuster",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Fork of postcss-cachebuster. Cachebusting all local files in css",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postcss",
|
|
@@ -33,20 +33,20 @@
|
|
|
33
33
|
},
|
|
34
34
|
"main": "./index.mjs",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"chalk": "^5.6.2",
|
|
38
|
-
"path": "^0.12.7"
|
|
36
|
+
"chalk": "^5.6.2"
|
|
39
37
|
},
|
|
40
38
|
"devDependencies": {
|
|
41
39
|
"@eslint/js": "^9.39.2",
|
|
42
40
|
"chai": "^6.2.2",
|
|
43
41
|
"eslint": "^9.39.2",
|
|
42
|
+
"eslint-config-prettier": "^10.1.8",
|
|
44
43
|
"eslint-plugin-n": "^17.23.1",
|
|
45
44
|
"globals": "^16.5.0",
|
|
46
45
|
"gulp": "^5.0.1",
|
|
47
46
|
"gulp-mocha": "^10.0.1",
|
|
48
47
|
"gulp-postcss": "^10.0.0",
|
|
49
48
|
"postcss": "^8.5.6",
|
|
49
|
+
"prettier": "^3.7.4",
|
|
50
50
|
"sinon": "^21.0.1",
|
|
51
51
|
"sinon-chai": "^4.0.1"
|
|
52
52
|
},
|
|
@@ -55,6 +55,8 @@
|
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"lint": "eslint .",
|
|
58
|
-
"test": "gulp --gulpfile gulpfile.mjs"
|
|
58
|
+
"test": "gulp --gulpfile gulpfile.mjs",
|
|
59
|
+
"format:check": "prettier . --check",
|
|
60
|
+
"format:write": "prettier . --write"
|
|
59
61
|
}
|
|
60
62
|
}
|
|
@@ -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>
|
package/.idea/vcs.xml
DELETED
package/eslint.config.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import js from "@eslint/js";
|
|
2
|
-
import globals from "globals";
|
|
3
|
-
import n from "eslint-plugin-n";
|
|
4
|
-
import {defineConfig} from "eslint/config";
|
|
5
|
-
|
|
6
|
-
export default defineConfig([
|
|
7
|
-
{
|
|
8
|
-
files: ["**/*.{js,mjs,cjs}"],
|
|
9
|
-
languageOptions: {
|
|
10
|
-
ecmaVersion: "latest",
|
|
11
|
-
sourceType: "module",
|
|
12
|
-
globals: {
|
|
13
|
-
...globals.node,
|
|
14
|
-
...globals.mocha,
|
|
15
|
-
myCustomGlobal: "readonly",
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
plugins: {js, n},
|
|
19
|
-
extends: ["js/recommended", "n/recommended"],
|
|
20
|
-
ignores: ['eslint.config.js'],
|
|
21
|
-
},
|
|
22
|
-
]);
|
package/postcss-cachebuster.iml
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
-
<exclude-output />
|
|
5
|
-
<content url="file://$MODULE_DIR$" />
|
|
6
|
-
<orderEntry type="inheritedJdk" />
|
|
7
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
-
</component>
|
|
9
|
-
</module>
|