-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
fix: style pollution on custom theme #190
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/vuejs/vitepress/o7flw7gvc |
@knightly-bot build this |
🌒 Knightly build enabled, release every night at 00:00 UTC (skip if no change) |
I think this export was added after this discussion: #157 (comment) // .vitepress/theme/index.js
import { defaultTheme } from 'vitepress'
import MyGlobalComp from './Comp.vue'
defaultTheme.enhanceApp = ({ app }) => {
app.component('MyGlobalComp', MyGlobalComp)
} But I see your point that it is impossible to use the theme without any styles. Maybe there is a way to opt out with an option in the |
@matias-capeletto The current implementation make importing import 'vitepress' // will import the css side effects as well I don't think they can be solved without some hacks. I am thinking user should import the default theme explicitly like: import defaultTheme from 'vitepress/dist/client/default-theme` Which is also recommended by the Customization Guide Maybe we can add exports alias in package.json to achieve something like import defaultTheme from 'vitepress/default-theme` And I think the import { enhanceApp } from 'vitepress'
enhanceApp(({ app }) => {
}) |
Yes, the change was not documented and I think it was still WIP. Totally agree that importing vitepress should not include the CSS.
|
When using a custom theme, the style from the default theme will be injected and polluting the custom theme (overrides) due to the styles import side effect from re-exporting the defaultTheme here:
vitepress/src/client/app/exports.ts
Line 29 in 18d18d2
Repro: https://codesandbox.io/s/vitepress-style-pollution-p5kvq?file=/index.md
This PR removed the redirecting as it does not seem to be used and users should always import the theme from
vitepress/dist/client/theme-default
explicitly.