vite-plugin-css-svg-mask-image 1.0.3 → 1.0.5

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.
Files changed (2) hide show
  1. package/dist/index.js +8 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -76,14 +76,11 @@ export function svgMaskPlugin(options = {}) {
76
76
  }
77
77
  },
78
78
  async transform(code, id) {
79
- if (!id.match(/\.(css|scss|sass)$/)) {
79
+ const idPath = id.replace(/\?.*$/, "");
80
+ if (!idPath.match(/\.(css|scss|sass)$/)) {
80
81
  return null;
81
82
  }
82
- const syntax = /\.(scss|sass)$/.test(id) ? postcssScss : undefined;
83
- const ast = postcss.parse(code, {
84
- from: id,
85
- ...(syntax && { parser: syntax }),
86
- });
83
+ const ast = postcssScss.parse(code, { from: id });
87
84
  let has_svg_functions = false;
88
85
  ast.walkDecls("mask-image", (decl) => {
89
86
  const value = decl.value.trim();
@@ -130,10 +127,11 @@ export function svgMaskPlugin(options = {}) {
130
127
  if (!has_svg_functions) {
131
128
  return null;
132
129
  }
133
- const processOpts = { from: id, to: id };
134
- if (syntax)
135
- processOpts.stringifier = postcssScss;
136
- const result = await postcss().process(ast, processOpts);
130
+ const result = await postcss().process(ast, {
131
+ from: id,
132
+ to: id,
133
+ stringifier: postcssScss,
134
+ });
137
135
  processed_files.add(id);
138
136
  return {
139
137
  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",
3
+ "version": "1.0.5",
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",