Skip to content

Conversation

byronogis
Copy link
Contributor

close #5604

自 unocss@66.1.0-beta.11 开始, 其内部移除了 unocss:global:build:bundle 插件, 使得当插入 uni:adjust-css-extname 插件时所依赖的插件成为了 unocss:global:build:generate, 造成无法获取 css 文件(此时 vite 内部还没有在 rollup 输出中添加 css 文件, 需要等到 vite:css-post 插件后), 因此这里直接使插件 uni:adjust-css-extname 的 generateBundle 钩子的排序为 post, 以便顺利获取到输出流程中的 css 文件进行处理

close dcloudio#5604

自 unocss@66.1.0-beta.11 开始, 其内部移除了 unocss:global:build:bundle 插件, 使得当插入 uni:adjust-css-extname 插件时所依赖的插件成为了 unocss:global:build:generate, 造成无法获取 css 文件(此时 vite 内部还没有在 rollup 输出中添加 css 文件, 需要等到 vite:css-post 插件后), 因此这里直接使插件 uni:adjust-css-extname 的 generateBundle 钩子的排序为 post, 以便顺利获取到输出流程中的 css 文件进行处理
@chouchouji
Copy link
Contributor

chouchouji commented Jul 2, 2025

感谢您的贡献,需要确认两个问题

  1. 会不会影响低版本的unocss的使用
  2. 会不会影响没有使用unocss的项目

byronogis added a commit to byronogis/project-starter that referenced this pull request Jul 2, 2025
@byronogis
Copy link
Contributor Author

感谢您的贡献,需要确认两个问题

  1. 会不会影响低版本的unocss的使用
  2. 会不会影响没有使用unocss的项目
  1. 不会( 在 65.5.0 的 unocss 版本测试过
  2. 不会( 尝试过禁用 unocss 插件也可正常生成

@Otto-J Otto-J requested a review from Copilot July 3, 2025 11:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures the uni:adjust-css-extname plugin can access CSS files by running its generateBundle hook after Vite’s CSS emission.

  • Changed generateBundle hook to use an object form with order: 'post' and a handler function.
  • Ensures plugin waits for the vite:css-post phase before renaming CSS file extensions.
Comments suppressed due to low confidence (2)

packages/uni-mp-vite/src/plugin/configResolved.ts:215

  • [nitpick] Consider adding a comment explaining why order: 'post' is necessary so future maintainers understand that it ensures CSS files are emitted by vite:css-post before this hook runs.
    generateBundle: {

packages/uni-mp-vite/src/plugin/configResolved.ts:217

  • It would be helpful to add or update tests to verify that CSS files are correctly processed when this plugin runs in post-order, ensuring the uni:adjust-css-extname behavior works as intended.
      handler(_, bundle) {

@chouchouji chouchouji merged commit d89d9c8 into dcloudio:next Aug 25, 2025
4 checks passed
@chouchouji
Copy link
Contributor

感谢您的贡献

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

从 unocss@66.1.0-beta.11 版本开始(含) 不能正常转换小程序平台的 css 文件后缀
2 participants