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

postcss-pxtorem didn't work as envisaged #15993

Closed
7 tasks done
Zoeyxyz opened this issue Feb 21, 2024 · 4 comments
Closed
7 tasks done

postcss-pxtorem didn't work as envisaged #15993

Zoeyxyz opened this issue Feb 21, 2024 · 4 comments

Comments

@Zoeyxyz
Copy link

Zoeyxyz commented Feb 21, 2024

Describe the bug

config like this

css: {
    postcss: {
      plugins: [
        postCssPxToRem({
          rootValue({ file }) {
            return file.indexOf("vant") !== -1 ? 37.5 : 75;
          },
          propList: ["*"],
        }),
      ],
    },
},
server: {}

main.js

import { createApp } from 'vue'
import vant from 'vant'
import 'vant/lib/index.css'
import 'amfe-flexible'
import App from './App.vue'

createApp(App).use(vant).mount('#app')

Reproduction

https://stackblitz.com/edit/vitejs-vite-jbu2zx?file=vite.config.js,package.json,index.html,public%2Fvite.svg,src%2FApp.vue&terminal=dev

Steps to reproduce

No response

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i9-13900H
    Memory: 16.48 GB / 31.73 GB
  Binaries:
    Node: 18.19.0 - D:\Program Files\nodejs\node.EXE
    Yarn: 1.22.21 - D:\Program Files\nodejs\yarn.CMD
    npm: 10.2.5 - D:\Program Files\nodejs\npm.CMD
    pnpm: 8.14.0 - D:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (121.0.2277.128)
    Internet Explorer: 11.0.22621.1

Used Package Manager

npm

Logs

No response

Validations

Copy link

stackblitz bot commented Feb 21, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@bluwy
Copy link
Member

bluwy commented Feb 21, 2024

Can you explain what is not working? It seems to transform for me:

.logo[data-v-7a7a37b1] {
  width: 2.66667rem;
  height: 2.66667rem;
}

@sapphi-red sapphi-red added the cannot reproduce The bug cannot be reproduced label Feb 21, 2024
@Zoeyxyz
Copy link
Author

Zoeyxyz commented Feb 22, 2024

Can you explain what is not working? It seems to transform for me:

.logo[data-v-7a7a37b1] {
  width: 2.66667rem;
  height: 2.66667rem;
}

vant's style is wrong

--van-font-size-md: 0.18667rem;

It should be

--van-font-size-md: 0.37333rem;

@sapphi-red
Copy link
Member

This is a bug in postcss-pxtorem (cuth/postcss-pxtorem#103).
I got the following log by adding some console.log in the plugin.

once /mnt/c/Users/green/Downloads/vitejs-vite-jbu2zx/node_modules/vant/lib/index.css
once /mnt/c/Users/green/Downloads/vitejs-vite-jbu2zx/src/App.vue?vue&type=style&index=0&scoped=7a7a37b1&lang.css
decl /mnt/c/Users/green/Downloads/vitejs-vite-jbu2zx/src/App.vue?vue&type=style&index=0&scoped=7a7a37b1&lang.css
decl /mnt/c/Users/green/Downloads/vitejs-vite-jbu2zx/src/App.vue?vue&type=style&index=0&scoped=7a7a37b1&lang.css
decl /mnt/c/Users/green/Downloads/vitejs-vite-jbu2zx/node_modules/vant/lib/index.css
decl /mnt/c/Users/green/Downloads/vitejs-vite-jbu2zx/node_modules/vant/lib/index.css
decl /mnt/c/Users/green/Downloads/vitejs-vite-jbu2zx/node_modules/vant/lib/index.css

@sapphi-red sapphi-red removed the cannot reproduce The bug cannot be reproduced label Feb 22, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants