vite.config.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { defineConfig, loadEnv, splitVendorChunkPlugin } from "vite";
  2. import react from "@vitejs/plugin-react";
  3. import obfuscatorPlugin from "vite-plugin-javascript-obfuscator";
  4. // https://vitejs.dev/config/
  5. export default ({ mode }) =>
  6. defineConfig({
  7. // eslint-disable-next-line no-undef
  8. base: loadEnv(mode, process.cwd()).VITE_PUBLIC_DIR,
  9. server: {
  10. port: 3888,
  11. },
  12. plugins: [
  13. react({
  14. jsxImportSource: "@emotion/react",
  15. babel: {
  16. plugins: ["@emotion/babel-plugin"],
  17. },
  18. }),
  19. splitVendorChunkPlugin(),
  20. obfuscatorPlugin({
  21. apply: "build",
  22. options: {
  23. debugProtection: false,
  24. compact: true,
  25. controlFlowFlattening: true,
  26. controlFlowFlatteningThreshold: 0.75,
  27. deadCodeInjection: true,
  28. deadCodeInjectionThreshold: 0.4,
  29. debugProtectionInterval: 0,
  30. disableConsoleOutput: true,
  31. identifierNamesGenerator: "hexadecimal",
  32. log: false,
  33. numbersToExpressions: true,
  34. renameGlobals: false,
  35. selfDefending: true,
  36. simplify: true,
  37. splitStrings: true,
  38. splitStringsChunkLength: 10,
  39. stringArray: true,
  40. stringArrayCallsTransform: true,
  41. stringArrayCallsTransformThreshold: 0.75,
  42. stringArrayEncoding: ["base64"],
  43. stringArrayIndexShift: true,
  44. stringArrayRotate: true,
  45. stringArrayShuffle: true,
  46. stringArrayWrappersCount: 2,
  47. stringArrayWrappersChainedCalls: true,
  48. stringArrayWrappersParametersMaxCount: 4,
  49. stringArrayWrappersType: "function",
  50. stringArrayThreshold: 0.75,
  51. transformObjectKeys: true,
  52. unicodeEscapeSequence: false,
  53. },
  54. }),
  55. ],
  56. });