Skip to content
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: add ?import for vite-ignore import for md files #3173

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/client/app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function pathToFile(path: string) {
pagePath = pagePath.replace(/\/$/, '/index') // /foo/ -> /foo/index
if (import.meta.env.DEV) {
// always force re-fetch content in dev
pagePath += `.md?t=${Date.now()}`
pagePath += `.md?${__IS_VITE_4__ ? '' : 'import&'}t=${Date.now()}`
} else {
// in production, each .md file is built into a .md.js file following
// the path conversion scheme.
Expand Down
1 change: 1 addition & 0 deletions src/client/shim.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ declare const __ALGOLIA__: boolean
declare const __CARBON__: boolean
declare const __VUE_PROD_DEVTOOLS__: boolean
declare const __ASSETS_DIR__: string
declare const __IS_VITE_4__: boolean

declare module '*.vue' {
import type { DefineComponent } from 'vue'
Expand Down
4 changes: 3 additions & 1 deletion src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import c from 'picocolors'
import {
mergeConfig,
searchForWorkspaceRoot,
version,
type ModuleNode,
type Plugin,
type ResolvedConfig,
Expand Down Expand Up @@ -153,7 +154,8 @@ export async function createVitePressPlugin(
site.themeConfig?.search?.provider === 'algolia' ||
!!site.themeConfig?.algolia, // legacy
__CARBON__: !!site.themeConfig?.carbonAds,
__ASSETS_DIR__: JSON.stringify(siteConfig.assetsDir)
__ASSETS_DIR__: JSON.stringify(siteConfig.assetsDir),
__IS_VITE_4__: version.split('.')[0] === '4'
},
optimizeDeps: {
// force include vue to avoid duplicated copies when linked + optimized
Expand Down