vite-plugin-style-to-vw
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -10,4 +10,2 @@ interface IdefaultsProp { | ||
type VitePluginStyleToVw = (options?: IdefaultsProp)=>any | ||
export { IdefaultsProp, VitePluginStyleToVw, VitePluginStyleToVw as default }; | ||
export { IdefaultsProp }; |
@@ -1,1 +0,1 @@ | ||
"use strict";var y=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var i in e)y(t,i,{get:e[i],enumerable:!0})},S=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of P(e))!v.call(t,a)&&a!==i&&y(t,a,{get:()=>e[a],enumerable:!(n=x(e,a))||n.enumerable});return t};var b=t=>S(y({},"__esModule",{value:!0}),t);var U={};m(U,{default:()=>T});module.exports=b(U);var h={unitToConvert:"px",viewportWidth:750,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",minPixelValue:1};function M(t,e){let i=Math.pow(10,e+1),n=Math.floor(t*i);return Math.round(n/10)*10/i}function w(t,e,i,n){return function(a,r){if(!r)return;let s=parseFloat(r);if(!(s<=e))return M(s/t*100,i)+n}}var g=/<template>([\s\S]+)<\/template>/gi,o=/(\d+)px/g,p=/style\s*(:|=)\s*(?:"([^"]*?)"|'([^']*?)'|{([^}]*)})/g,R=(t=h)=>({name:"vite-plugin-style-to-vw",transform(e,i){if(t=Object.assign(h,t),/.vue$/.test(i)){let n="",a="";if(g.test(e)?(n=e.match(g)[0],a=e.match(g)[0]):e.includes("setup")&&(n=e,a=e),p.test(n)){let r=n.match(p);if(r?.length){let s=[];for(let l=0;l<r.length;l++){let f=r[l].replace(o,c=>c.replace(o,w(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));s.push(f)}let u=n;for(let l=0;l<r.length;l++)u=u.replace(r[l],`${s[l]}`);e=e.replace(a,u)}}}else if(/\.tsx|\.jsx$/.test(i)){let n=e,a=e;if(p.test(n)){let r=n.match(p);if(r?.length){let s=[];for(let l=0;l<r.length;l++){let f=r[l].replace(o,c=>c.replace(o,w(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));s.push(f)}let u=n;for(let l=0;l<r.length;l++)u=u.replace(r[l],`${s[l]}`);e=e.replace(a,u)}}}return{code:e}}}),T=R;0&&(module.exports={}); | ||
"use strict";var y=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var P=(t,e)=>{for(var i in e)y(t,i,{get:e[i],enumerable:!0})},b=(t,e,i,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of V(e))!m.call(t,a)&&a!==i&&y(t,a,{get:()=>e[a],enumerable:!(l=v(e,a))||l.enumerable});return t};var S=t=>b(y({},"__esModule",{value:!0}),t);var _={};P(_,{default:()=>U});module.exports=S(_);var g={unitToConvert:"px",viewportWidth:750,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",minPixelValue:1};function M(t,e){let i=Math.pow(10,e+1),l=Math.floor(t*i);return Math.round(l/10)*10/i}function w(t,e,i,l){return function(a,r){if(!r)return;let s=parseFloat(r);if(!(s<=e))return M(s/t*100,i)+l}}var h=/<template>([\s\S]+)<\/template>/gi,o=/(\d+)px/g,p=/style\s*(:|=)\s*(?:"([^"]*?)"|'([^']*?)'|{([^}]*)})/g;function R(t=g){return{name:"vite-plugin-style-to-vw",transform(e,i){if(t=Object.assign(g,t),/.vue$/.test(i)){let l="",a="";if(h.test(e)?(l=e.match(h)[0],a=e.match(h)[0]):e.includes("setup")&&(l=e,a=e),p.test(l)){let r=l.match(p);if(r?.length){let s=[];for(let n=0;n<r.length;n++){let f=r[n].replace(o,c=>c.replace(o,w(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));s.push(f)}let u=l;for(let n=0;n<r.length;n++)u=u.replace(r[n],`${s[n]}`);e=e.replace(a,u)}}}else if(/\.tsx|\.jsx$/.test(i)){let l=e,a=e;if(p.test(l)){let r=l.match(p);if(r?.length){let s=[];for(let n=0;n<r.length;n++){let f=r[n].replace(o,c=>c.replace(o,w(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));s.push(f)}let u=l;for(let n=0;n<r.length;n++)u=u.replace(r[n],`${s[n]}`);e=e.replace(a,u)}}}return{code:e}}}}var U=R;0&&(module.exports={}); |
{ | ||
"name": "vite-plugin-style-to-vw", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "一个可以将签内样式px转换vw的plugin", | ||
@@ -5,0 +5,0 @@ "exports": { |
@@ -0,1 +1,2 @@ | ||
import { Plugin } from "vite"; | ||
export interface IdefaultsProp { | ||
@@ -10,4 +11,3 @@ unitToConvert: string, | ||
export type VitePluginStyleToVw = (options?: IdefaultsProp)=>any | ||
export default VitePluginStyleToVw | ||
declare function vitePluginStyleToVw (options?: IdefaultsProp): Plugin; | ||
@@ -1,2 +0,2 @@ | ||
import type { IdefaultsProp,VitePluginStyleToVw } from './index.d' | ||
import type { IdefaultsProp } from './index.d' | ||
@@ -39,3 +39,3 @@ // 默认参数 | ||
const vitePluginStyleToVw :VitePluginStyleToVw = (customOptions: IdefaultsProp = defaultsProp)=> { | ||
function vitePluginStyleToVw(customOptions: IdefaultsProp = defaultsProp) { | ||
return { | ||
@@ -42,0 +42,0 @@ // 插件名称 |
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
20855