vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.29k stars 27.02k forks source link

PostCSS Configuration Is a Function #44619

Open SouthLink opened 1 year ago

SouthLink commented 1 year ago

Verify canary release

Provide environment information

Operating System: Platform: win32 Arch: x64 Version: Windows 10 Pro Binaries: Node: 16.8.0 npm: N/A Yarn: N/A pnpm: N/A Relevant packages: next: 13.1.1 eslint-config-next: 13.1.1 react: 18.2.0 react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue

https://codesandbox.io/s/hopeful-tom-97quw8?file=/postcss.config.js

To Reproduce

// postcss.config.js
module.exports = ({ file }) => {
  let isDouble = file.includes("Vw") ? 750 : 375;
  return {
    plugins: {
      "@tcstory/postcss-px-to-viewport": {
        viewportWidth: isDouble,
        viewportHeight: 1334,
        unitPrecision: 1,
        viewportUnit: "vw",
        selectorBlackList: [".ignore", ".hairlines"],
        minPixelValue: 1,
        mediaQuery: false,
        exclude: [/^((?!(|m|M)obile).)+$/]
      }
    }
  };
};

Describe the Bug

I want to support the following functions in postcss.config.js, which support px/vw conversion according to the file. The following operations are supported in webpack, and nextjs 10.0.9 also supports them, Please tell me how to solve it

Expected Behavior

postcss.config Support functional

Which browser are you using? (if relevant)

chrome 108.0.5359.72

How are you deploying your application? (if relevant)

No response

SouthLink commented 1 year ago

No one?