Skip to content

Commit

Permalink
Change: VITE_IS_XXXをVITE_TARGETに (#1406)
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi authored Jul 17, 2023
1 parent 7a597e7 commit b8bd84c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
"npm": "8.19.3"
},
"scripts": {
"serve": "cross-env VITE_IS_ELECTRON=false vite",
"build": "cross-env VITE_IS_ELECTRON=false vite build",
"test:unit": "vitest --run",
"test-watch:unit": "vitest --watch",
"test:e2e": "playwright test",
Expand All @@ -24,12 +22,13 @@
"markdownlint": "markdownlint --ignore node_modules/ --ignore dist/ --ignore dist_electron/ ./",
"typecheck": "tsc --noEmit",
"typecheck:vue-tsc": "vue-tsc --noEmit",
"electron:build": "cross-env VITE_IS_ELECTRON=true vite build && electron-builder --config electron-builder.config.js",
"electron:build_dir": "cross-env VITE_IS_ELECTRON=true vite build && electron-builder --config electron-builder.config.js --dir",
"electron:build_pnever": "cross-env VITE_IS_ELECTRON=true vite build && electron-builder --config electron-builder.config.js --publish never",
"electron:build": "cross-env VITE_TARGET=electron vite build && electron-builder --config electron-builder.config.js",
"electron:build_dir": "cross-env VITE_TARGET=electron vite build && electron-builder --config electron-builder.config.js --dir",
"electron:build_pnever": "cross-env VITE_TARGET=electron vite build && electron-builder --config electron-builder.config.js --publish never",
"electron:build_pnever_prepackaged": "cross-var electron-builder --config electron-builder.config.js --publish never --prepackaged $PREPACKAGED",
"electron:serve": "cross-env VITE_IS_ELECTRON=true vite",
"browser:serve": "cross-env VITE_IS_ELECTRON=false VITE_IS_BROWSER=true vite",
"electron:serve": "cross-env VITE_TARGET=electron vite",
"browser:serve": "cross-env VITE_TARGET=browser vite",
"browser:build": "cross-env VITE_TARGET=browser vite build",
"postinstall": "electron-builder install-app-deps && node build/download7z.js",
"postuninstall": "electron-builder install-app-deps",
"license:generate": "node build/generateLicenses.js",
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const config: PlaywrightTestConfig = {
// outputDir: 'test-results/',

webServer: {
command: "cross-env VITE_IS_ELECTRON=true vite --mode test",
command: "cross-env VITE_TARGET=electron vite --mode test",
port: 5173,
reuseExistingServer: !process.env.CI,
},
Expand Down
9 changes: 5 additions & 4 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
} from "vue-router";
import EditorHome from "../views/EditorHome.vue";

import { isElectron } from "@/type/preload";

const routes: Array<RouteRecordRaw> = [
{
path: "/home",
Expand All @@ -15,10 +17,9 @@ const routes: Array<RouteRecordRaw> = [
];

const router = createRouter({
history:
import.meta.env.VITE_IS_ELECTRON === "true"
? createWebHashHistory(import.meta.env.BASE_URL)
: createWebHistory(import.meta.env.BASE_URL),
history: isElectron
? createWebHashHistory(import.meta.env.BASE_URL)
: createWebHistory(import.meta.env.BASE_URL),
routes,
});

Expand Down
2 changes: 2 additions & 0 deletions src/type/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { IpcSOData } from "./ipc";
import { AltPortInfos } from "@/store/type";
import { Result } from "@/type/result";

export const isElectron = import.meta.env.VITE_TARGET === "electron";
export const isBrowser = import.meta.env.VITE_TARGET === "browser";
export const isMac =
typeof process === "undefined"
? navigator.userAgent.includes("Mac")
Expand Down
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { quasar } from "@quasar/vite-plugin";

rmSync(path.resolve(__dirname, "dist"), { recursive: true, force: true });

const isElectron = process.env.VITE_IS_ELECTRON === "true";
const isBrowser = process.env.VITE_IS_BROWSER === "true";
const isElectron = process.env.VITE_TARGET === "electron";
const isBrowser = process.env.VITE_TARGET === "browser";

export default defineConfig((options) => {
const shouldEmitSourcemap = ["development", "test"].includes(options.mode);
Expand Down

0 comments on commit b8bd84c

Please sign in to comment.