vite.config.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { defineConfig } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import VueDevTools from "vite-plugin-vue-devtools";
  4. import tailwindcss from "@tailwindcss/postcss";
  5. import autoprefixer from "autoprefixer";
  6. import { fileURLToPath } from "node:url";
  7. import path from "node:path";
  8. import { readFileSync } from "node:fs";
  9. const __dirname = path.dirname(fileURLToPath(import.meta.url));
  10. const pkg = JSON.parse(readFileSync(path.resolve(__dirname, "package.json"), "utf-8"));
  11. export default defineConfig(({ command }) => ({
  12. define: {
  13. __APP_VERSION__: JSON.stringify(pkg.version)
  14. },
  15. resolve: {
  16. alias: {
  17. "@": path.resolve(__dirname, "src")
  18. }
  19. },
  20. plugins: command === "serve"
  21. ? [VueDevTools({ launchEditor: fileURLToPath(new URL("./scripts/launch-editor-trae.sh", import.meta.url)) }), vue()]
  22. : [vue()],
  23. css: {
  24. postcss: {
  25. plugins: [tailwindcss(), autoprefixer()]
  26. }
  27. },
  28. build: {
  29. rollupOptions: {
  30. output: {
  31. // separa as libs do código da aplicação para que um deploy não invalide o cache delas
  32. manualChunks: {
  33. vue: ["vue", "vue-router"],
  34. markdown: ["marked", "dompurify"],
  35. highlight: ["highlight.js"],
  36. toast: ["vue-toastification"]
  37. }
  38. }
  39. }
  40. },
  41. server: {
  42. port: 5173
  43. }
  44. }));