vite-plugin-css-svg-mask-image 1.0.4 → 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.
Potentially problematic release.
This version of vite-plugin-css-svg-mask-image might be problematic. Click here for more details.
- package/dist/index.js +4 -13
- 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,15 +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
|
|
84
|
-
const ast = postcss.parse(code, {
|
|
85
|
-
from: id,
|
|
86
|
-
...(syntax && { parser: syntax }),
|
|
87
|
-
});
|
|
81
|
+
const ast = postcss.parse(code);
|
|
88
82
|
let has_svg_functions = false;
|
|
89
83
|
ast.walkDecls("mask-image", (decl) => {
|
|
90
84
|
const value = decl.value.trim();
|
|
@@ -131,10 +125,7 @@ export function svgMaskPlugin(options = {}) {
|
|
|
131
125
|
if (!has_svg_functions) {
|
|
132
126
|
return null;
|
|
133
127
|
}
|
|
134
|
-
const
|
|
135
|
-
if (syntax)
|
|
136
|
-
processOpts.stringifier = postcssScss;
|
|
137
|
-
const result = await postcss().process(ast, processOpts);
|
|
128
|
+
const result = await postcss().process(ast, { from: id, to: id });
|
|
138
129
|
processed_files.add(id);
|
|
139
130
|
return {
|
|
140
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"
|