You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using a custom theme, importing composables like useRoute from "vitepress" in the Layout component also imports the styles for the default theme.
Run yarn docs:dev and open http://localhost:3000. Note the heading doesn't have any styles applied to it:
Uncomment the lines in the <script setup> section in docs/.vitepress/theme/Layout.vue. Note the heading now has the default styles applied to it, even though we only imported useRoute:
Expected behavior
The heading should remain unstyled since we aren't explicitly importing any styles.
System Info
vitepress version: v0.9.2
vite version: v1.0.0-rc.13
Node version: v12.20.0
OS version: macOS Catalina 10.15.7
Additional context
I had a quick look at the Vitepress code and it looks like the problem might be to do with this line:
mrbbot
changed the title
Importing default composables also imports default theme's stlyes
Importing default composables also imports default theme's styles
Dec 10, 2020
This one also tripped me up when I upgraded from version 0.8.1 to latest, I got around it by importing the exactly what I needed.
This causes the styles from the default theme to be applied:
import { useSiteData } from 'vitepress'
This does what we'd expect without the leakage:
import { useSiteData } from 'vitepress/dist/client/app/composables/siteData'
With the suggestion of importing for the default theme from this issue #190 would it make sense / be possible to remove the default theme export from the types/index.d.ts file? (assuming that is the culript)
This issue is fixed in the latest code. Importing things like useSiteData will not include styles. So the styles are only included when you actually do import DefaultTheme from 'vitepress/theme' 👍
Describe the bug
When using a custom theme, importing composables like
useRoute
from"vitepress"
in the Layout component also imports the styles for the default theme.To Reproduce
docs/.vitepress/theme/Layout.vue
with the following contents:docs/.vitepress/theme/index.js
with the following contents:yarn docs:dev
and open http://localhost:3000. Note the heading doesn't have any styles applied to it:<script setup>
section indocs/.vitepress/theme/Layout.vue
. Note the heading now has the default styles applied to it, even though we only importeduseRoute
:Expected behavior
The heading should remain unstyled since we aren't explicitly importing any styles.
System Info
Additional context
I had a quick look at the Vitepress code and it looks like the problem might be to do with this line:
vitepress/src/client/app/exports.ts
Line 29 in 309aa7a
Adding the following to
docs/.vitepress/config.js
:...and creating an empty file
docs/.vitepress/theme/empty.js
prevents the default styles being applied.The text was updated successfully, but these errors were encountered: