Skip to content

Commit f8cdc9e

Browse files
committed
fix: workaround for vite hash issue (close #1008)
1 parent 8171f4d commit f8cdc9e

File tree

15 files changed

+117
-41
lines changed

15 files changed

+117
-41
lines changed

ecosystem/plugin-active-header-links/src/node/activeHeaderLinksPlugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ export const activeHeaderLinksPlugin = ({
5050

5151
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
5252

53+
alias: {
54+
// workaround for https://github.com/vitejs/vite/issues/7621
55+
'@vuepress/plugin-active-header-links/client': path.resolve(
56+
__dirname,
57+
'../client/index.js'
58+
),
59+
},
60+
5361
define: {
5462
__AHL_HEADER_LINK_SELECTOR__: headerLinkSelector,
5563
__AHL_HEADER_ANCHOR_SELECTOR__: headerAnchorSelector,

ecosystem/plugin-back-to-top/src/node/backToTopPlugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,12 @@ export const backToTopPlugin = (): Plugin => ({
77
name: '@vuepress/plugin-back-to-top',
88

99
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
10+
11+
alias: {
12+
// workaround for https://github.com/vitejs/vite/issues/7621
13+
'@vuepress/plugin-back-to-top/client': path.resolve(
14+
__dirname,
15+
'../client/index.js'
16+
),
17+
},
1018
})

ecosystem/plugin-docsearch/src/node/docsearchPlugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ export const docsearchPlugin = (options: DocsearchPluginOptions): Plugin => ({
1111

1212
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
1313

14+
alias: {
15+
// workaround for https://github.com/vitejs/vite/issues/7621
16+
'@vuepress/plugin-docsearch/client': path.resolve(
17+
__dirname,
18+
'../client/index.js'
19+
),
20+
},
21+
1422
define: {
1523
__DOCSEARCH_OPTIONS__: options,
1624
},

ecosystem/plugin-external-link-icon/src/node/externalLinkIconPlugin.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,20 @@ export const externalLinkIconPlugin = ({
2020
}: ExternalLinkIconPluginOptions = {}): Plugin => ({
2121
name: '@vuepress/plugin-external-link-icon',
2222

23+
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
24+
25+
alias: {
26+
// workaround for https://github.com/vitejs/vite/issues/7621
27+
'@vuepress/plugin-external-link-icon/client': path.resolve(
28+
__dirname,
29+
'../client/index.js'
30+
),
31+
},
32+
2333
define: {
2434
__EXTERNAL_LINK_ICON_LOCALES__: locales,
2535
},
2636

27-
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
28-
2937
extendsMarkdown: (md) => {
3038
let shouldRenderExternalIcon = false
3139

ecosystem/plugin-google-analytics/src/node/googleAnalyticsPlugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ export const googleAnalyticsPlugin =
3434

3535
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
3636

37+
alias: {
38+
// workaround for https://github.com/vitejs/vite/issues/7621
39+
'@vuepress/plugin-google-analytics/client': path.resolve(
40+
__dirname,
41+
'../client/index.js'
42+
),
43+
},
44+
3745
define: {
3846
__GA_ID__: id,
3947
},

ecosystem/plugin-medium-zoom/src/node/mediumZoomPlugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ export const mediumZoomPlugin = ({
3939

4040
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
4141

42+
alias: {
43+
// workaround for https://github.com/vitejs/vite/issues/7621
44+
'@vuepress/plugin-medium-zoom/client': path.resolve(
45+
__dirname,
46+
'../client/index.js'
47+
),
48+
},
49+
4250
define: {
4351
__MZ_SELECTOR__: selector,
4452
__MZ_ZOOM_OPTIONS__: zoomOptions,

ecosystem/plugin-nprogress/src/node/nprogressPlugin.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,14 @@ const __dirname = getDirname(import.meta.url)
55

66
export const nprogressPlugin = (): Plugin => ({
77
name: '@vuepress/plugin-nprogress',
8+
89
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
10+
11+
alias: {
12+
// workaround for https://github.com/vitejs/vite/issues/7621
13+
'@vuepress/plugin-nprogress/client': path.resolve(
14+
__dirname,
15+
'../client/index.js'
16+
),
17+
},
918
})

ecosystem/plugin-pwa-popup/src/node/pwaPopupPlugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ export const pwaPopupPlugin =
3333

3434
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
3535

36+
alias: {
37+
// workaround for https://github.com/vitejs/vite/issues/7621
38+
'@vuepress/plugin-pwa-popup/client': path.resolve(
39+
__dirname,
40+
'../client/index.js'
41+
),
42+
},
43+
3644
define: {
3745
__PWA_POPUP_LOCALES__: locales,
3846
},

ecosystem/plugin-pwa/src/node/pwaPlugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ export const pwaPlugin =
3939

4040
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
4141

42+
alias: {
43+
// workaround for https://github.com/vitejs/vite/issues/7621
44+
'@vuepress/plugin-pwa/client': path.resolve(
45+
__dirname,
46+
'../client/index.js'
47+
),
48+
},
49+
4250
define: {
4351
__PWA_SW_FILENAME__: serviceWorkerFilename,
4452
},

ecosystem/plugin-search/src/node/searchPlugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ export const searchPlugin = ({
5858

5959
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
6060

61+
alias: {
62+
// workaround for https://github.com/vitejs/vite/issues/7621
63+
'@vuepress/plugin-search/client': path.resolve(
64+
__dirname,
65+
'../client/index.js'
66+
),
67+
},
68+
6169
define: {
6270
__SEARCH_LOCALES__: locales,
6371
__SEARCH_HOT_KEYS__: hotKeys,

ecosystem/plugin-theme-data/src/node/themeDataPlugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ export const themeDataPlugin = ({
2020
}: ThemeDataPluginOptions): Plugin => ({
2121
name: '@vuepress/plugin-theme-data',
2222

23+
alias: {
24+
// workaround for https://github.com/vitejs/vite/issues/7621
25+
'@vuepress/plugin-theme-data/client': path.resolve(
26+
__dirname,
27+
'../client/index.js'
28+
),
29+
},
30+
2331
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
2432

2533
onPrepared: (app) => prepareThemeData(app, themeData),

ecosystem/plugin-toc/src/node/tocPlugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ export const tocPlugin = ({
2929

3030
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
3131

32+
alias: {
33+
// workaround for https://github.com/vitejs/vite/issues/7621
34+
'@vuepress/plugin-toc/client': path.resolve(
35+
__dirname,
36+
'../client/index.js'
37+
),
38+
},
39+
3240
define: {
3341
__TOC_COMPONENT_NAME__: componentName,
3442
__TOC_DEFAULT_PROPS_OPTIONS__: defaultPropsOptions,

ecosystem/theme-default/src/node/defaultTheme.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,24 @@ export const defaultTheme = ({
4343

4444
templateBuild: path.resolve(__dirname, '../../templates/build.html'),
4545

46-
// use alias to make all components replaceable
47-
alias: Object.fromEntries(
48-
fs
49-
.readdirSync(path.resolve(__dirname, '../client/components'))
50-
.filter((file) => file.endsWith('.vue'))
51-
.map((file) => [
52-
`@theme/${file}`,
53-
path.resolve(__dirname, '../client/components', file),
54-
])
55-
),
46+
alias: {
47+
// use alias to make all components replaceable
48+
...Object.fromEntries(
49+
fs
50+
.readdirSync(path.resolve(__dirname, '../client/components'))
51+
.filter((file) => file.endsWith('.vue'))
52+
.map((file) => [
53+
`@theme/${file}`,
54+
path.resolve(__dirname, '../client/components', file),
55+
])
56+
),
57+
58+
// workaround for https://github.com/vitejs/vite/issues/7621
59+
'@vuepress/theme-default/client': path.resolve(
60+
__dirname,
61+
'../client/index.js'
62+
),
63+
},
5664

5765
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
5866

packages/bundler-vite/src/plugins/vuepressPlugin.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { App } from '@vuepress/core'
22
import type { Plugin } from 'vite'
33
import { constantsReplacementPlugin } from './constantsReplacementPlugin.js'
44
import { mainPlugin } from './mainPlugin.js'
5-
// import { workaroundPlugin } from './workaroundPlugin.js'
65

76
export const vuepressPlugin = ({
87
app,
@@ -19,5 +18,4 @@ export const vuepressPlugin = ({
1918
isBuild,
2019
isServer,
2120
}),
22-
// workaroundPlugin(),
2321
]

packages/bundler-vite/src/plugins/workaroundPlugin.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)