Skip to content

fix: styles import order#2512

Merged
antfu merged 6 commits into
slidevjs:mainfrom
kermanx:fix/2495
Apr 8, 2026
Merged

fix: styles import order#2512
antfu merged 6 commits into
slidevjs:mainfrom
kermanx:fix/2495

Conversation

@kermanx

@kermanx kermanx commented Mar 29, 2026

Copy link
Copy Markdown
Member

fixes #2495. closes #2511.

  • The core problem is that import.meta.glob-imported styles are always moved to the top of the file; that's why fix: import order with import.meta.glob #2457 was proposed.
  • However, the order of @unocss/reset/tailwind.css and uno:*.css was still wrong.
  • This PR moves the styles order to a dedicated packages/client/styles/index.ts, and conditional (import.meta.glob) styles are loaded in #slidev/conditional-styles.
  • One problem is why import 'uno.css' was the last one to import (before the related PRs)? This behavior is kept in this PR.

@netlify

netlify Bot commented Mar 29, 2026

Copy link
Copy Markdown

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 0604bf4
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/69d5bed8b262ce00086cf814
😎 Deploy Preview https://deploy-preview-2512--slidev.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.

@pkg-pr-new

pkg-pr-new Bot commented Mar 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/@slidev/client@2512

create-slidev

npm i https://pkg.pr.new/create-slidev@2512

create-slidev-theme

npm i https://pkg.pr.new/create-slidev-theme@2512

@slidev/parser

npm i https://pkg.pr.new/@slidev/parser@2512

@slidev/cli

npm i https://pkg.pr.new/@slidev/cli@2512

@slidev/types

npm i https://pkg.pr.new/@slidev/types@2512

commit: d5fb2bb

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 restructures how Slidev client styles are imported to preserve a deterministic CSS order, addressing regressions caused by import.meta.glob hoisting.

Changes:

  • Replaces the previous /@slidev/styles virtual module with a dedicated client entry at packages/client/styles/index.ts.
  • Introduces a new virtual module (#slidev/conditional-styles) to load user/theme style globs (and other conditional CSS).
  • Updates the client bootstrap to import the new centralized styles entry.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/types/client.d.ts Renames the side-effect-only virtual module typing to #slidev/conditional-styles.
packages/slidev/node/virtual/styles.ts Removes the old virtual module that generated the full style import chain.
packages/slidev/node/virtual/index.ts Registers the new conditional-styles virtual template.
packages/slidev/node/virtual/conditional-styles.ts Adds a new virtual module responsible for import.meta.glob-driven style loading (and feature conditionals).
packages/client/styles/index.ts New central “style entry” defining the desired CSS import order and delegating conditional imports to the virtual module.
packages/client/setup/main.ts Switches from #slidev/styles to importing the new client styles entry.

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

Comment thread packages/client/styles/index.ts
Comment thread packages/slidev/node/virtual/conditional-styles.ts
Comment thread packages/slidev/node/virtual/index.ts Outdated
Comment thread packages/client/setup/main.ts Outdated
@antfu
antfu merged commit 56ac81c into slidevjs:main Apr 8, 2026
9 of 11 checks passed
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.

Styles are appllied in incorrect order

3 participants