|
@@ -42,7 +42,13 @@ module.exports = defineConfig(({ mode }) => {
|
|
|
const output = platformBuild?.output;
|
|
const output = platformBuild?.output;
|
|
|
const outDir = output ? `dist/${output}` : "dist";
|
|
const outDir = output ? `dist/${output}` : "dist";
|
|
|
|
|
|
|
|
|
|
+ // 预览模式下通过 PREVIEW_BASE_PATH 设置 base,如 /ads-preview/
|
|
|
|
|
+ // 这会控制 Vite 注入的 @vite/client 路径 + 所有 JS import 模块路径的前缀
|
|
|
|
|
+ const base = process.env.PREVIEW_BASE_PATH || undefined;
|
|
|
|
|
+ if (base) console.log(`[vite:config] base = ${base}`);
|
|
|
|
|
+
|
|
|
return {
|
|
return {
|
|
|
|
|
+ base,
|
|
|
plugins: [viteSingleFile(), finalizeHtmlPlugin(outDir, adapter)],
|
|
plugins: [viteSingleFile(), finalizeHtmlPlugin(outDir, adapter)],
|
|
|
server: {
|
|
server: {
|
|
|
allowedHosts: ["color2.jccytech.cn", "localhost", ".jccytech.cn"],
|
|
allowedHosts: ["color2.jccytech.cn", "localhost", ".jccytech.cn"],
|