mirror of https://github.com/halo-dev/halo
fix: unable to compile console and uc on Windows platform (#4877)
#### What type of PR is this? /kind bug /area console /milestone 2.11.x #### What this PR does / why we need it: 修复在 Windows 平台下无法正常启动 Console 服务以及无法正常编译的问题。 <img width="1124" alt="图片" src="https://github.com/halo-dev/halo/assets/21301288/55edd00a-8e71-437e-8889-0fe4a43bb40b"> #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/4874 #### Special notes for your reviewer: 在 Windows 平台下测试 `pnpm dev` 和 `pnpm build`,检查是否能够正常运行。 #### Does this PR introduce a user-facing change? ```release-note None ```pull/4882/head
parent
747cab3aa1
commit
fbc9045908
|
@ -1,4 +1,4 @@
|
||||||
import { fileURLToPath, URL } from "url";
|
import { fileURLToPath } from "url";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { defineConfig, type Plugin } from "vite";
|
import { defineConfig, type Plugin } from "vite";
|
||||||
import Vue from "@vitejs/plugin-vue";
|
import Vue from "@vitejs/plugin-vue";
|
||||||
|
@ -7,6 +7,7 @@ import { VitePWA } from "vite-plugin-pwa";
|
||||||
import Icons from "unplugin-icons/vite";
|
import Icons from "unplugin-icons/vite";
|
||||||
import { setupLibraryExternal } from "./library-external";
|
import { setupLibraryExternal } from "./library-external";
|
||||||
import GzipPlugin from "rollup-plugin-gzip";
|
import GzipPlugin from "rollup-plugin-gzip";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
interface Options {
|
interface Options {
|
||||||
base: string;
|
base: string;
|
||||||
|
@ -49,6 +50,9 @@ export function createViteConfig(options: Options) {
|
||||||
|
|
||||||
const { base, entryFile, port, outDir, plugins } = options;
|
const { base, entryFile, port, outDir, plugins } = options;
|
||||||
|
|
||||||
|
const currentFileDir = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const rootDir = path.resolve(currentFileDir, "../..");
|
||||||
|
|
||||||
return defineConfig({
|
return defineConfig({
|
||||||
base,
|
base,
|
||||||
plugins: [
|
plugins: [
|
||||||
|
@ -58,9 +62,9 @@ export function createViteConfig(options: Options) {
|
||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"@": fileURLToPath(new URL("/src", import.meta.url)),
|
"@": path.resolve(rootDir, "src"),
|
||||||
"@console": fileURLToPath(new URL("/console-src", import.meta.url)),
|
"@console": path.resolve(rootDir, "console-src"),
|
||||||
"@uc": fileURLToPath(new URL("/uc-src", import.meta.url)),
|
"@uc": path.resolve(rootDir, "uc-src"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
|
@ -70,7 +74,7 @@ export function createViteConfig(options: Options) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
outDir: fileURLToPath(new URL(outDir, import.meta.url)),
|
outDir: path.resolve(rootDir, outDir),
|
||||||
emptyOutDir: true,
|
emptyOutDir: true,
|
||||||
chunkSizeWarningLimit: 2048,
|
chunkSizeWarningLimit: 2048,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue