vite-plugin-style-to-vw
Advanced tools
Comparing version 1.0.6 to 1.0.7
{ | ||
"name": "vite-plugin-style-to-vw", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "一个可以将签内样式px转换vw的plugin", | ||
@@ -5,0 +5,0 @@ "exports": { |
109
README.md
# vite-plugin-style-to-vw | ||
一个可以将 标签内样式 px 转换 vw 的 plugin | ||
A plugin that can convert intra-tag style px to vw | ||
## Language | ||
## 安装 | ||
- [English](https://github.com/cq112233/vite-plugin-style-to-vw/blob/master/README.md) | ||
- [中文](https://github.com/cq112233/vite-plugin-style-to-vw/blob/master/README.zh-CN.md) | ||
## Install | ||
``` | ||
@@ -18,15 +23,14 @@ npm install vite-plugin-style-to-vw -D | ||
## 使用 必须写在vue()前面 | ||
## Basic use | ||
vite.config.js | ||
### Vue, must be written before vue () | ||
```javascript | ||
import vitePluginStyleToVw from "vite-plugin-style-to-vw"; | ||
import { defineConfig } from "vite"; | ||
import vue from "@vitejs/plugin-vue"; | ||
import vitePluginStyleToVw from "vite-plugin-style-to-vw"; | ||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
base: process.env.NODE_ENV === "production" ? "./" : "/", | ||
plugins: [vitePluginStyleToVw({ | ||
@@ -40,20 +44,30 @@ unitToConvert: "px", | ||
}), vue()], | ||
resolve: { | ||
alias: { | ||
"@": fileURLToPath(new URL("./src", import.meta.url)), | ||
}, | ||
}, | ||
}); | ||
``` | ||
## 示例 | ||
### react | ||
### vue 文件 | ||
```javascript | ||
import { defineConfig } from 'vite' | ||
import react from '@vitejs/plugin-react' | ||
import vitePluginStyleToVw from 'vite-plugin-style-to-vw'; | ||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [ | ||
vitePluginStyleToVw(), | ||
react() | ||
], | ||
}) | ||
``` | ||
// 一行写法 | ||
## Support for vue,tsx,jsx file import | ||
### Input | ||
```html | ||
<h3 style="font-size: 28px;margin-top: 10px;width:500px">Test</h3> | ||
// 换行写法 | ||
<h3 style=" | ||
@@ -65,15 +79,24 @@ font-size: 28px; | ||
// 对象写法 | ||
<h3 | ||
:style="{fontSize:'28px',marginTop: '10px'}"> | ||
Test</h3> | ||
<h3 | ||
style={{font-size:'28px';margin-top: '10px'}}> | ||
Test</h3> | ||
<h3 | ||
style= | ||
{{font-size:'28px'; | ||
margin-top: '10px'}} | ||
> | ||
Test</h3> | ||
``` | ||
### 输出 | ||
### Output | ||
```html | ||
// 一行写法 | ||
<h3 style="font-size: 3.73333ww;margin-top: 1.33333vw;width:66.6667vw">Test</h3> | ||
// 换行写法 | ||
<h3 style=" | ||
@@ -85,56 +108,36 @@ font-size: 3.73333ww; | ||
// 对象写法 | ||
<h3 | ||
style="font-size: 3.73333ww;margin-top: 1.33333vw;"> | ||
Test</h3> | ||
``` | ||
# 也支持tsx,jsx 文件 | ||
### 输入 | ||
``` | ||
<h3 | ||
style={{font-size:'28px';margin-top: '10px'}}> | ||
Test</h3> | ||
<h3 | ||
style= | ||
{{font-size:'28px'; | ||
margin-top: '10px'}} | ||
> | ||
Test</h3> | ||
``` | ||
### 输出 | ||
``` | ||
<h3 | ||
<h3 | ||
style="font-size: 3.73333ww;margin-top: 1.33333vw;"> | ||
Test</h3> | ||
<h3 | ||
<h3 | ||
style="font-size: 3.73333ww;margin-top: 1.33333vw;" | ||
> | ||
Test</h3> | ||
``` | ||
### 如果你不想转换 请用PX代替 | ||
``` | ||
### If you don't want to switch, please use PX instead. | ||
## Configuration parameters | ||
## 配置参数 | ||
**Default configuration** | ||
**默认配置:** | ||
```javascript | ||
{ | ||
unitToConvert: "px", // 需要转换的单位,默认为"px" | ||
viewportWidth: 750, // 设计稿的视口宽度,如传入函数,函数的参数为当前处理的文件路径 | ||
unitPrecision: 5, // 单位转换后保留的精度 | ||
viewportUnit: "vw", // 希望使用的视口单位 | ||
fontViewportUnit: "vw", // 字体使用的视口单位 | ||
minPixelValue: 1, // 设置最小的转换数值,如果为 1 的话,只有大于 1 的值会被转换 | ||
unitToConvert: "px", // The unit to be converted is "px" by default. | ||
viewportWidth: 750, // The viewport width of the design draft, such as the incoming function, whose parameter is the file path currently processed. | ||
unitPrecision: 5, // Precision retained after unit conversion. | ||
viewportUnit: "vw", // Viewport units you want to use. | ||
fontViewportUnit: "vw", // Viewport units used by fonts. | ||
minPixelValue: 1, // Set the minimum conversion value. If it is 1, only values greater than 1 will be converted. | ||
} | ||
``` | ||
借鉴 vite-plugin-style-vw-loader | ||
Draw lessons from vite-plugin-style-vw-loader | ||
https://github.com/gitboyzcf/vite-plugin-style-vw-loader |
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
26440
14
139