@vendure/dashboard 3.3.5-master-202506201217 → 3.3.5-master-202506201219
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugin/vite-plugin-transform-index.d.ts +11 -0
- package/dist/plugin/vite-plugin-transform-index.js +33 -0
- package/dist/plugin/vite-plugin-vendure-dashboard.js +2 -0
- package/package.json +4 -4
- package/vite/vite-plugin-transform-index.ts +38 -0
- package/vite/vite-plugin-vendure-dashboard.ts +2 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* @description
|
|
4
|
+
* This Vite plugin handles the scenario where the `base` path is set in the Vite config.
|
|
5
|
+
* The default Vite behavior is to prepend the `base` path to all `href` and `src` attributes in the HTML,
|
|
6
|
+
* but this causes the Vendure Dashboard not to load its assets correctly.
|
|
7
|
+
*
|
|
8
|
+
* This plugin removes the `base` path from all `href` and `src` attributes in the HTML,
|
|
9
|
+
* and adds a `<base>` tag to the `<head>` of the HTML document.
|
|
10
|
+
*/
|
|
11
|
+
export declare function transformIndexHtmlPlugin(): Plugin;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
* This Vite plugin handles the scenario where the `base` path is set in the Vite config.
|
|
4
|
+
* The default Vite behavior is to prepend the `base` path to all `href` and `src` attributes in the HTML,
|
|
5
|
+
* but this causes the Vendure Dashboard not to load its assets correctly.
|
|
6
|
+
*
|
|
7
|
+
* This plugin removes the `base` path from all `href` and `src` attributes in the HTML,
|
|
8
|
+
* and adds a `<base>` tag to the `<head>` of the HTML document.
|
|
9
|
+
*/
|
|
10
|
+
export function transformIndexHtmlPlugin() {
|
|
11
|
+
let config;
|
|
12
|
+
return {
|
|
13
|
+
name: 'vendure:vite-config-transform-index-html',
|
|
14
|
+
configResolved(resolvedConfig) {
|
|
15
|
+
// store the resolved config
|
|
16
|
+
config = resolvedConfig;
|
|
17
|
+
},
|
|
18
|
+
transformIndexHtml(html) {
|
|
19
|
+
if (config.base && config.base !== '/') {
|
|
20
|
+
// Remove the base path from hrefs and srcs
|
|
21
|
+
const basePath = config.base.replace(/\/$/, ''); // Remove trailing slash
|
|
22
|
+
// Single regex to handle both href and src attributes with any quote type
|
|
23
|
+
const attributeRegex = new RegExp(`(href|src)=(["'])${basePath}`, 'g');
|
|
24
|
+
let transformedHtml = html.replace(attributeRegex, '$1=$2');
|
|
25
|
+
// Add base tag to head
|
|
26
|
+
const baseTag = ` <base href="${config.base}">\n`;
|
|
27
|
+
transformedHtml = transformedHtml.replace(/<head>/, `<head>\n${baseTag}`);
|
|
28
|
+
return transformedHtml;
|
|
29
|
+
}
|
|
30
|
+
return html;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -8,6 +8,7 @@ import { viteConfigPlugin } from './vite-plugin-config.js';
|
|
|
8
8
|
import { dashboardMetadataPlugin } from './vite-plugin-dashboard-metadata.js';
|
|
9
9
|
import { gqlTadaPlugin } from './vite-plugin-gql-tada.js';
|
|
10
10
|
import { themeVariablesPlugin } from './vite-plugin-theme.js';
|
|
11
|
+
import { transformIndexHtmlPlugin } from './vite-plugin-transform-index.js';
|
|
11
12
|
import { uiConfigPlugin } from './vite-plugin-ui-config.js';
|
|
12
13
|
/**
|
|
13
14
|
* @description
|
|
@@ -54,6 +55,7 @@ export function vendureDashboardPlugin(options) {
|
|
|
54
55
|
...(options.gqlTadaOutputPath
|
|
55
56
|
? [gqlTadaPlugin({ gqlTadaOutputPath: options.gqlTadaOutputPath, tempDir, packageRoot })]
|
|
56
57
|
: []),
|
|
58
|
+
transformIndexHtmlPlugin(),
|
|
57
59
|
];
|
|
58
60
|
}
|
|
59
61
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure/dashboard",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "3.3.5-master-
|
|
4
|
+
"version": "3.3.5-master-202506201219",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"@types/react-dom": "^19.0.4",
|
|
87
87
|
"@types/react-grid-layout": "^1.3.5",
|
|
88
88
|
"@uidotdev/usehooks": "^2.4.1",
|
|
89
|
-
"@vendure/common": "^3.3.5-master-
|
|
90
|
-
"@vendure/core": "^3.3.5-master-
|
|
89
|
+
"@vendure/common": "^3.3.5-master-202506201219",
|
|
90
|
+
"@vendure/core": "^3.3.5-master-202506201219",
|
|
91
91
|
"@vitejs/plugin-react": "^4.3.4",
|
|
92
92
|
"awesome-graphql-client": "^2.1.0",
|
|
93
93
|
"class-variance-authority": "^0.7.1",
|
|
@@ -130,5 +130,5 @@
|
|
|
130
130
|
"lightningcss-linux-arm64-musl": "^1.29.3",
|
|
131
131
|
"lightningcss-linux-x64-musl": "^1.29.1"
|
|
132
132
|
},
|
|
133
|
-
"gitHead": "
|
|
133
|
+
"gitHead": "b691fcec88df06276514b8f71a3c0a414b9ead88"
|
|
134
134
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Plugin, ResolvedConfig } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* This Vite plugin handles the scenario where the `base` path is set in the Vite config.
|
|
6
|
+
* The default Vite behavior is to prepend the `base` path to all `href` and `src` attributes in the HTML,
|
|
7
|
+
* but this causes the Vendure Dashboard not to load its assets correctly.
|
|
8
|
+
*
|
|
9
|
+
* This plugin removes the `base` path from all `href` and `src` attributes in the HTML,
|
|
10
|
+
* and adds a `<base>` tag to the `<head>` of the HTML document.
|
|
11
|
+
*/
|
|
12
|
+
export function transformIndexHtmlPlugin(): Plugin {
|
|
13
|
+
let config: ResolvedConfig;
|
|
14
|
+
return {
|
|
15
|
+
name: 'vendure:vite-config-transform-index-html',
|
|
16
|
+
configResolved(resolvedConfig) {
|
|
17
|
+
// store the resolved config
|
|
18
|
+
config = resolvedConfig;
|
|
19
|
+
},
|
|
20
|
+
transformIndexHtml(html) {
|
|
21
|
+
if (config.base && config.base !== '/') {
|
|
22
|
+
// Remove the base path from hrefs and srcs
|
|
23
|
+
const basePath = config.base.replace(/\/$/, ''); // Remove trailing slash
|
|
24
|
+
|
|
25
|
+
// Single regex to handle both href and src attributes with any quote type
|
|
26
|
+
const attributeRegex = new RegExp(`(href|src)=(["'])${basePath}`, 'g');
|
|
27
|
+
let transformedHtml = html.replace(attributeRegex, '$1=$2');
|
|
28
|
+
|
|
29
|
+
// Add base tag to head
|
|
30
|
+
const baseTag = ` <base href="${config.base}">\n`;
|
|
31
|
+
transformedHtml = transformedHtml.replace(/<head>/, `<head>\n${baseTag}`);
|
|
32
|
+
|
|
33
|
+
return transformedHtml;
|
|
34
|
+
}
|
|
35
|
+
return html;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -10,6 +10,7 @@ import { viteConfigPlugin } from './vite-plugin-config.js';
|
|
|
10
10
|
import { dashboardMetadataPlugin } from './vite-plugin-dashboard-metadata.js';
|
|
11
11
|
import { gqlTadaPlugin } from './vite-plugin-gql-tada.js';
|
|
12
12
|
import { ThemeVariablesPluginOptions, themeVariablesPlugin } from './vite-plugin-theme.js';
|
|
13
|
+
import { transformIndexHtmlPlugin } from './vite-plugin-transform-index.js';
|
|
13
14
|
import { UiConfigPluginOptions, uiConfigPlugin } from './vite-plugin-ui-config.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -92,6 +93,7 @@ export function vendureDashboardPlugin(options: VitePluginVendureDashboardOption
|
|
|
92
93
|
...(options.gqlTadaOutputPath
|
|
93
94
|
? [gqlTadaPlugin({ gqlTadaOutputPath: options.gqlTadaOutputPath, tempDir, packageRoot })]
|
|
94
95
|
: []),
|
|
96
|
+
transformIndexHtmlPlugin(),
|
|
95
97
|
];
|
|
96
98
|
}
|
|
97
99
|
|