Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

设计稿 375 宽度时使用 postcss-pxtransform 转换失败,需要配置 deviceRatio #14729

Closed
jc-yang opened this issue Oct 31, 2023 · 0 comments · Fixed by #14726 or #14811
Closed
Labels
enhancement New feature or request
Milestone

Comments

@jc-yang
Copy link
Contributor

jc-yang commented Oct 31, 2023

这个特性解决了什么问题?

代码示例:
https://codesandbox.io/p/sandbox/condescending-wind-fdmttz?file=%2Fvite.config.ts%3A14%2C12

375 是常见设计稿宽度,目前使用插件配置宽度 375 时仍需显式配置 deviceRatio,否则样式转换后为 NaNpxNaNrpx 等,导致样式错误。

image

期望在使用 375 设计稿做插件的最小配置时无需配置 deviceRatio

这个 API 长什么样?

import { defineConfig } from "vite";
import pxtransfrom from "postcss-pxtransform";

// https://vitejs.dev/config/
export default defineConfig({
  css: {
    postcss: {
      plugins: [
        pxtransfrom({
          platform: "h5",
          designWidth: 375, // 设计稿宽度375
        }),
      ],
    },
  },
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants