vite-plugin-style-to-vw
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -1,1 +0,1 @@ | ||
"use strict";var w=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var i in e)w(t,i,{get:e[i],enumerable:!0})},N=(t,e,i,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of b(e))!S.call(t,a)&&a!==i&&w(t,a,{get:()=>e[a],enumerable:!(l=v(e,a))||l.enumerable});return t};var M=t=>N(w({},"__esModule",{value:!0}),t);var I={};m(I,{default:()=>R,stylePxToVw:()=>C});module.exports=M(I);var o={unitToConvert:"px",viewportWidth:750,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",minPixelValue:1};function U(t,e){let i=Math.pow(10,e+1),l=Math.floor(t*i);return Math.round(l/10)*10/i}function g(t,e,i,l){return function(a,n){if(n=Number(n),!n)return a;let u=parseFloat(n);return u<=e?a:U(u/t*100,i)+l}}var V=o,P=/<template>([\s\S]+)<\/template>/gi,p=/(\d+)px/g,h=/style\s*(:|=)\s*(?:"([^"]*?)"|'([^']*?)'|{([^}]*)})/g,c=/style.setProperty\(.*\)/g;function W(t=o){return{name:"vite-plugin-style-to-vw",transform(e,i){if(t=Object.assign(o,t),V=t,/.vue$/.test(i)){let l="",a="";if(P.test(e)?(l=e.match(P)[0],a=e.match(P)[0]):e.includes("setup")&&(l=e,a=e),h.test(l)){let n=l.match(h);if(n?.length){let u=[];for(let r=0;r<n.length;r++){let f=n[r].replace(p,y=>y.replace(p,g(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));u.push(f)}let s=l;for(let r=0;r<n.length;r++)s=s.replace(n[r],`${u[r]}`);e=e.replace(a,s)}}}else if(/\.tsx|\.jsx$/.test(i)){let l=e,a=e;if(h.test(l)){let n=l.match(h);if(n?.length){let u=[];for(let r=0;r<n.length;r++){let f=n[r].replace(p,y=>y.replace(p,g(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));u.push(f)}let s=l;for(let r=0;r<n.length;r++)s=s.replace(n[r],`${u[r]}`);e=e.replace(a,s),a=e,l=e}}if(c.test(l)){let n=l.match(c);if(n?.length){let u=[];for(let r=0;r<n.length;r++){let f=n[r].replace(p,y=>y.replace(p,g(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));u.push(f)}let s=l;for(let r=0;r<n.length;r++)s=s.replace(n[r],`${u[r]}`);e=e.replace(e,s)}}}return{code:e,map:null}}}}var R=W,C=(t,e=V)=>{if(e=Object.assign(V,e),typeof t=="number"||typeof Number(t)=="number"&&!isNaN(Number(t))){let i=t.toString().replace(/(\d+)/g,l=>l.replace(/(\d+)/g,g(e.viewportWidth,e.minPixelValue,e.unitPrecision,"")));return typeof t=="number"?Number(i):i}else return t.toString().replace(p,i=>i.replace(p,g(e.viewportWidth,e.minPixelValue,e.unitPrecision,e.viewportUnit)))};0&&(module.exports={stylePxToVw}); | ||
"use strict";var w=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var i in e)w(t,i,{get:e[i],enumerable:!0})},N=(t,e,i,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of b(e))!S.call(t,a)&&a!==i&&w(t,a,{get:()=>e[a],enumerable:!(l=v(e,a))||l.enumerable});return t};var M=t=>N(w({},"__esModule",{value:!0}),t);var I={};m(I,{default:()=>R,stylePxToVw:()=>C});module.exports=M(I);var P={unitToConvert:"px",viewportWidth:750,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",minPixelValue:1};function U(t,e){let i=Math.pow(10,e+1),l=Math.floor(t*i);return Math.round(l/10)*10/i}function g(t,e,i,l){return function(a,n){if(n=Number(n),!n)return a;let u=parseFloat(n);return u<=e?a:U(u/t*100,i)+l}}var V=P,o=/<template>([\s\S]+)<\/template>/gi,p=/(\d+)px/g,h=/style\s*(:|=)\s*(?:"([^"]*?)"|'([^']*?)'|{([^}]*)})/g,x=/style.setProperty\(.*\)/g;function W(t=P){return{name:"vite-plugin-style-to-vw",enforce:"pre",transform(e,i){if(t=Object.assign(P,t),V=t,/.vue$/.test(i)){let l="",a="";if(o.test(e)?(l=e.match(o)[0],a=e.match(o)[0]):e.includes("setup")&&(l=e,a=e),h.test(l)){let n=l.match(h);if(n?.length){let u=[];for(let r=0;r<n.length;r++){let f=n[r].replace(p,y=>y.replace(p,g(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));u.push(f)}let s=l;for(let r=0;r<n.length;r++)s=s.replace(n[r],`${u[r]}`);e=e.replace(a,s)}}}else if(/\.tsx|\.jsx$/.test(i)){let l=e,a=e;if(h.test(l)){let n=l.match(h);if(n?.length){let u=[];for(let r=0;r<n.length;r++){let f=n[r].replace(p,y=>y.replace(p,g(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));u.push(f)}let s=l;for(let r=0;r<n.length;r++)s=s.replace(n[r],`${u[r]}`);e=e.replace(a,s),a=e,l=e}}if(x.test(l)){let n=l.match(x);if(n?.length){let u=[];for(let r=0;r<n.length;r++){let f=n[r].replace(p,y=>y.replace(p,g(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));u.push(f)}let s=l;for(let r=0;r<n.length;r++)s=s.replace(n[r],`${u[r]}`);e=e.replace(e,s)}}}return{code:e,map:null}}}}var R=W,C=(t,e=V)=>{if(e=Object.assign(V,e),typeof t=="number"||typeof Number(t)=="number"&&!isNaN(Number(t))){let i=t.toString().replace(/(\d+)/g,l=>l.replace(/(\d+)/g,g(e.viewportWidth,e.minPixelValue,e.unitPrecision,"")));return typeof t=="number"?Number(i):i}else return t.toString().replace(p,i=>i.replace(p,g(e.viewportWidth,e.minPixelValue,e.unitPrecision,e.viewportUnit)))};0&&(module.exports={stylePxToVw}); |
{ | ||
"name": "vite-plugin-style-to-vw", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "一个可以将签内样式px转换vw的plugin", | ||
@@ -5,0 +5,0 @@ "exports": { |
@@ -45,2 +45,3 @@ import type { IdefaultsProp } from './index.d' | ||
name: "vite-plugin-style-to-vw", | ||
enforce: 'pre', | ||
// 构建阶段的通用钩子:在每个传入模块请求时被调用:在每个传入模块请求时被调用,主要是用来转换单个模块 | ||
@@ -47,0 +48,0 @@ transform(code: any, id: any) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25607
250