Skip to content

Conversation

@zyyv
Copy link
Member

@zyyv zyyv commented Jan 5, 2026

This PR changes the following:

Breaking Changes

  • Removed the default presetUno configuration; users now need to configure it manually ⚠️
    • Now, you can use --preset wind3 or --preset wind4 to switch as your default preset. But if you have configured uno.config, this option will be ignored.
  • Replaced --write-transformed with --rewrite

New Features and Optimizations

  • Added debug mode, allowing you to clearly see which files are scanned and collected. Enable with --debug
  • Added more granular parsing to patterns.
  • Allows users to manually decide whether to rewrite the transformer for custom scanned files.
{
  cli: {
    entry: {
      patterns: [
        './src/pages/**/*.vue',
      ],
      outFile: './src/unocss-generated.css',
+     rewrite: true
    },
  },
  transformers: [
    transformerDirectives(),
  ],
}
  • Allows users to decide whether to output scanned CSS with --split-css
    • false: Do not output CSS files
    • true: Transform and output scanned CSS file contents to outFile
    • 'multi': Output each CSS file separately with filename format ${outFile}-[hash]
    • 'single': Merge multiple CSS files into one output file named outFile-merged.css

This resolves the previous issue where CSS files would be automatically discarded when detected during scanning.
Fixed #4902

{
  cli: {
    entry: {
      patterns: [
        './src/pages/**/*.css',
      ],
      outFile: './src/unocss-generated.css',
+     splitCss: true
    },
  },
  transformers: [
    transformerDirectives(),
  ],
}

Copilot AI review requested due to automatic review settings January 5, 2026 07:57
@zyyv zyyv requested a review from antfu as a code owner January 5, 2026 07:57
@netlify
Copy link

netlify bot commented Jan 5, 2026

Deploy Preview for unocss ready!

Name Link
🔨 Latest commit 915543b
🔍 Latest deploy log https://app.netlify.com/projects/unocss/deploys/695e8284d4a5bd00084c7135
😎 Deploy Preview https://deploy-preview-5038--unocss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

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 refactors the CLI to implement smarter pattern analysis with significant structural changes to how files are processed and cached.

  • Extracts test utilities into a dedicated utils.ts file for better test organization
  • Refactors the main build logic to support multiple entry points with different output files and smarter CSS file detection
  • Removes default config and preset dependencies to make the engine more agnostic

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages-engine/cli/test/utils.ts New file containing extracted test helper functions including runCli, sleep, and test directory management utilities
packages-engine/cli/test/cli.test.ts Simplified to 2 active tests with snapshot assertions; 9 tests commented out reducing test coverage
packages-engine/cli/test/__snapshots__/cli.test.ts.snap Deleted old inline snapshot file
packages-engine/cli/test/__snapshots__/cli-scan-and-transform-css.snapshot.css New CSS snapshot file with absolute paths (needs fixing)
packages-engine/cli/test/__snapshots__/cli-build-uno.css.snapshot.css New CSS snapshot file for basic build test
packages-engine/cli/src/watcher.ts Updated type from CliOptions to ResolvedCliOptions; added mock watcher return for test cases
packages-engine/cli/src/types.ts Expanded with comprehensive JSDoc; restructured CliOptions and ResolvedCliOptions with new properties for entries and context
packages-engine/cli/src/index.ts Major refactor: new file cache structure, separate handling for CSS vs non-CSS files, extracted initializeConfig and generateSingle functions
packages-engine/cli/src/config.ts Removed default config that included preset-uno
packages-engine/cli/src/cli-start.ts Simplified entry handling; renamed --write-transformed to --rewrite; moved config loading into build function
packages-engine/cli/package.json Removed dependencies: @jridgewell/remapping, @unocss/preset-uno, unplugin-utils
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 5, 2026

Open in StackBlitz

commit: 915543b

@zyyv
Copy link
Member Author

zyyv commented Jan 7, 2026

Done!

@zyyv zyyv merged commit c2363ef into main Jan 7, 2026
12 checks passed
@zyyv zyyv deleted the refactor-cli branch January 7, 2026 16:07
@zyyv zyyv added this to the 66.6.0 milestone Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants