| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- import { defineConfig } from 'vite';
- import vue from '@vitejs/plugin-vue';
- import electron from 'vite-plugin-electron';
- import renderer from 'vite-plugin-electron-renderer';
- import AutoImport from 'unplugin-auto-import/vite';
- import Components from 'unplugin-vue-components/vite';
- import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
- import { resolve } from 'path';
- export default defineConfig(({ command }) => {
- const isServe = command === 'serve';
- const isBuild = command === 'build';
- return {
- resolve: {
- alias: {
- '@': resolve(__dirname, 'src'),
- },
- },
- plugins: [
- vue(),
- AutoImport({
- imports: ['vue', 'vue-router', 'pinia'],
- resolvers: [ElementPlusResolver()],
- dts: 'src/auto-imports.d.ts',
- }),
- Components({
- resolvers: [ElementPlusResolver()],
- dts: 'src/components.d.ts',
- }),
- electron([
- {
- entry: 'electron/main.ts',
- onstart(options) {
- if (process.env.VSCODE_DEBUG) {
- console.log('[startup] Electron App');
- } else {
- options.startup();
- }
- },
- vite: {
- build: {
- sourcemap: isServe,
- minify: isBuild,
- outDir: 'dist-electron',
- rollupOptions: {
- external: ['electron'],
- output: {
- format: 'cjs',
- },
- },
- },
- },
- },
- {
- entry: 'electron/preload.ts',
- onstart(options) {
- options.reload();
- },
- vite: {
- build: {
- sourcemap: isServe ? 'inline' : undefined,
- minify: isBuild,
- outDir: 'dist-electron',
- rollupOptions: {
- external: ['electron'],
- output: {
- format: 'cjs',
- },
- },
- },
- },
- },
- ]),
- renderer(),
- ],
- css: {
- preprocessorOptions: {
- scss: {
- additionalData: `@use "@/styles/variables.scss" as *;`,
- },
- },
- },
- server: {
- port: 5173,
- proxy: {
- '/api': {
- target: 'http://localhost:3000',
- changeOrigin: true,
- },
- '/ws': {
- target: 'ws://localhost:3000',
- ws: true,
- },
- },
- },
- build: {
- outDir: 'dist',
- emptyOutDir: true,
- },
- };
- });
|