123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- import { defineConfig } from "vite";
- import react from "@vitejs/plugin-react";
- import path, { resolve } from "path";
- import electron from "vite-plugin-electron";
- import electronRenderer from "vite-plugin-electron-renderer";
- import pkg from "./package.json";
- import viteCompression from "vite-plugin-compression";
- export default defineConfig(({ command }) => {
- const isServe = command === "serve";
- const isBuild = command === "build";
- const sourcemap = isServe || !!process.env.VSCODE_DEBUG;
- return {
- base: "./",
- publicDir: path.resolve(__dirname, "public"),
- plugins: [
- react(),
- electron([
- {
-
- entry: "electron/main",
- onstart(options) {
- if (process.env.VSCODE_DEBUG) {
- console.log(
- "[startup] Electron App"
- );
- } else {
- options.startup();
- }
- },
- vite: {
- build: {
- sourcemap,
- minify: isBuild,
- outDir: "dist-electron/main",
- rollupOptions: {
- external: Object.keys(
- "dependencies" in pkg ? pkg.dependencies : {}
- ),
- },
- },
- },
- },
- {
- entry: "electron/preload",
- onstart(options) {
-
-
- options.reload();
- },
- vite: {
- build: {
- sourcemap: sourcemap ? "inline" : undefined,
- minify: isBuild,
- outDir: "dist-electron/preload",
- rollupOptions: {
- external: Object.keys(
- "dependencies" in pkg ? pkg.dependencies : {}
- ),
- },
- },
- },
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]),
- electronRenderer(),
-
- viteCompression({
-
- verbose: true,
- disable: false,
- threshold: 10240,
- algorithm: "gzip",
- ext: ".gz",
- }),
- ],
- build: {
-
- outDir: "dist-electron",
- cssCodeSplit: true,
- chunkSizeWarningLimit: 1500,
- rollupOptions: {
- input: "index.html",
- output: {
-
- chunkFileNames: "assets/js/[name]-[hash].js",
- entryFileNames: "assets/js/[name]-[hash].js",
- assetFileNames: "assets/[ext]/[name]-[hash].[ext]",
- manualChunks(id) {
- if (id.includes("node_modules")) {
- return id
- .toString()
- .split("node_modules/")[1]
- .split("/")[0]
- .toString();
- }
- },
- },
- },
- terserOptions: {
-
- compress: {
- drop_console: true,
- drop_debugger: true,
- },
- },
- },
- server: {
- host: "localhost",
- port: 3010,
- strictPort: true,
- proxy: {
- "/api": {
- target: "http://localhost:3003",
- changeOrigin: true,
-
- },
- "/notification": {
- target: "http://114.215.252.134:8989",
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/notification/, ""),
- },
- "/userLogin": {
- target: "http://182.44.10.206:8000",
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/userLogin/, ""),
- },
- },
- },
- resolve: {
- alias: {
- "@": resolve(".", "./src"),
- },
- },
- };
- });
|