vite.config.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { defineConfig } from "vite";
  2. import path from "path";
  3. import svgr from "vite-plugin-svgr";
  4. import react from "@vitejs/plugin-react";
  5. import legacy from "@vitejs/plugin-legacy";
  6. import monacoEditor from "vite-plugin-monaco-editor";
  7. export default defineConfig({
  8. root: "src",
  9. server: { port: 3000 },
  10. plugins: [
  11. svgr(),
  12. react(),
  13. legacy({
  14. targets: ["edge>=109", "safari>=13"],
  15. modernPolyfills: true,
  16. polyfills: ["web.structured-clone"],
  17. additionalModernPolyfills: [
  18. "matchmedia-polyfill",
  19. "matchmedia-polyfill/matchMedia.addListener",
  20. path.resolve("./src/polyfills/WeakRef.js"),
  21. path.resolve("./src/polyfills/RegExp.js"),
  22. ],
  23. }),
  24. monacoEditor({
  25. languageWorkers: ["editorWorkerService", "typescript", "css"],
  26. customWorkers: [
  27. {
  28. label: "yaml",
  29. entry: "monaco-yaml/yaml.worker",
  30. },
  31. ],
  32. }),
  33. ],
  34. build: {
  35. outDir: "../dist",
  36. emptyOutDir: true,
  37. },
  38. resolve: {
  39. alias: {
  40. "@": path.resolve("./src"),
  41. "@root": path.resolve("."),
  42. },
  43. },
  44. define: {
  45. OS_PLATFORM: `"${process.platform}"`,
  46. },
  47. });