vite-plugin-css-svg-mask-image 1.0.5 → 1.0.6
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/dist/index.js +4 -10
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { readFileSync, existsSync, writeFileSync, mkdirSync } from "fs";
|
|
2
2
|
import { join, resolve, dirname } from "path";
|
|
3
3
|
import postcss, { Declaration } from "postcss";
|
|
4
|
-
import postcssScss from "postcss-scss";
|
|
5
4
|
function parse_svg_function(value) {
|
|
6
5
|
const match = value.match(/^['"]?([^'",]+)['"]?\s*(?:,\s*['"]?([^'"]+)['"]?)?$/);
|
|
7
6
|
if (!match) {
|
|
@@ -65,7 +64,7 @@ export function svgMaskPlugin(options = {}) {
|
|
|
65
64
|
};
|
|
66
65
|
return {
|
|
67
66
|
name: "vite-plugin-css-svg-mask-image",
|
|
68
|
-
enforce: "
|
|
67
|
+
enforce: "post",
|
|
69
68
|
buildStart() {
|
|
70
69
|
const icons_dir = dirname(resolved_icons_file);
|
|
71
70
|
if (!existsSync(icons_dir)) {
|
|
@@ -76,11 +75,10 @@ export function svgMaskPlugin(options = {}) {
|
|
|
76
75
|
}
|
|
77
76
|
},
|
|
78
77
|
async transform(code, id) {
|
|
79
|
-
|
|
80
|
-
if (!idPath.match(/\.(css|scss|sass)$/)) {
|
|
78
|
+
if (!id.match(/\.(css|scss|sass)$/)) {
|
|
81
79
|
return null;
|
|
82
80
|
}
|
|
83
|
-
const ast =
|
|
81
|
+
const ast = postcss.parse(code);
|
|
84
82
|
let has_svg_functions = false;
|
|
85
83
|
ast.walkDecls("mask-image", (decl) => {
|
|
86
84
|
const value = decl.value.trim();
|
|
@@ -127,11 +125,7 @@ export function svgMaskPlugin(options = {}) {
|
|
|
127
125
|
if (!has_svg_functions) {
|
|
128
126
|
return null;
|
|
129
127
|
}
|
|
130
|
-
const result = await postcss().process(ast, {
|
|
131
|
-
from: id,
|
|
132
|
-
to: id,
|
|
133
|
-
stringifier: postcssScss,
|
|
134
|
-
});
|
|
128
|
+
const result = await postcss().process(ast, { from: id, to: id });
|
|
135
129
|
processed_files.add(id);
|
|
136
130
|
return {
|
|
137
131
|
code: result.css,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-css-svg-mask-image",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Vite plugin to transform CSS/SCSS files with svg() mask-image function calls to CSS variables",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -38,8 +38,7 @@
|
|
|
38
38
|
"vitest": "^4.0.18"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"postcss": "^8.5.6"
|
|
42
|
-
"postcss-scss": "^4.0.9"
|
|
41
|
+
"postcss": "^8.5.6"
|
|
43
42
|
},
|
|
44
43
|
"peerDependencies": {
|
|
45
44
|
"vite": "^7.0.0"
|