You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.8 KiB

1 month ago
  1. import { defineConfig,loadEnv} from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import path from "path";
  4. import { rmSync } from "fs";
  5. import electron from "vite-plugin-electron";
  6. import { resolve } from 'path'
  7. rmSync('dist', { recursive: true, force: true });
  8. rmSync('node_modules/electron-edge-js/build', { recursive: true, force: true })
  9. export default defineConfig(({ mode }) => {
  10. const env = loadEnv(mode, __dirname)
  11. return {
  12. plugins: [
  13. vue(),
  14. electron([
  15. {
  16. entry: 'src/background.ts',
  17. vite: {
  18. build: {
  19. sourcemap: false,
  20. outDir: 'electron',
  21. rollupOptions: {
  22. // Here are some C/C++ plugins that can't be built properly.
  23. external: [
  24. 'electron-edge-js',
  25. ],
  26. },
  27. },
  28. },
  29. },
  30. {
  31. entry: 'src/preload.ts',
  32. vite: {
  33. build: {
  34. sourcemap: false,
  35. outDir: 'electron',
  36. rollupOptions: {
  37. // Here are some C/C++ plugins that can't be built properly.
  38. external: [
  39. 'electron-edge-js',
  40. ],
  41. },
  42. },
  43. },
  44. },
  45. ])
  46. ],
  47. esbuild: {
  48. drop: ['console', 'debugger'],
  49. },
  50. base: './',
  51. alias: {
  52. "@": path.resolve(__dirname, 'src'),
  53. '*': resolve('')
  54. },
  55. build: {
  56. outDir: "dist",
  57. assetsDir: "assets", //指定静态资源存放路径
  58. sourcemap: false, //是否构建source map 文件
  59. // terserOptions: {
  60. // // 生产环境移除console
  61. // compress: {
  62. // drop_console: true,
  63. // drop_debugger: true,
  64. // },
  65. // },
  66. },
  67. }
  68. })