vite.config.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. renderLegacyChunks: false,
  15. modernTargets: ["edge>=109", "safari>=13"],
  16. modernPolyfills: true,
  17. additionalModernPolyfills: [
  18. "core-js/modules/es.object.has-own.js",
  19. "core-js/modules/web.structured-clone.js",
  20. path.resolve("./src/polyfills/matchMedia.js"),
  21. path.resolve("./src/polyfills/WeakRef.js"),
  22. path.resolve("./src/polyfills/RegExp.js"),
  23. ],
  24. }),
  25. monacoEditor({
  26. languageWorkers: ["editorWorkerService", "typescript", "css"],
  27. customWorkers: [
  28. {
  29. label: "yaml",
  30. entry: "monaco-yaml/yaml.worker",
  31. },
  32. ],
  33. }),
  34. ],
  35. build: {
  36. outDir: "../dist",
  37. emptyOutDir: true,
  38. },
  39. resolve: {
  40. alias: {
  41. "@": path.resolve("./src"),
  42. "@root": path.resolve("."),
  43. },
  44. },
  45. define: {
  46. OS_PLATFORM: `"${process.platform}"`,
  47. },
  48. });