vite.config.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { defineConfig } from 'vite';
  2. import obfuscatorPlugin from 'vite-plugin-javascript-obfuscator';
  3. import { node } from 'vite-plugin-node';
  4. import dts from 'vite-plugin-dts';
  5. export default defineConfig({
  6. plugins: [
  7. // node(),
  8. dts(),
  9. obfuscatorPlugin({
  10. include: ["dist/tsbuild/**/*.js"],
  11. exclude: [/node_modules/],
  12. apply: "build",
  13. debugger: true,
  14. options: {
  15. debugProtection:false,
  16. debugProtectionInterval:0,
  17. // ... [See more options](https://github.com/javascript-obfuscator/javascript-obfuscator)
  18. compact: true,
  19. controlFlowFlattening: false,
  20. controlFlowFlatteningThreshold: 0.5,
  21. deadCodeInjection: false,
  22. deadCodeInjectionThreshold: 0.2,
  23. disableConsoleOutput: true,
  24. identifierNamesGenerator: 'hexadecimal',
  25. log: false,
  26. renameGlobals: false,
  27. rotateStringArray: true,
  28. selfDefending: false,
  29. stringArray: true,
  30. stringArrayEncoding: ['base64'],
  31. stringArrayThreshold: 0.5,
  32. transformObjectKeys: false,
  33. unicodeEscapeSequence: false
  34. },
  35. }),
  36. ],
  37. build: {
  38. lib: {
  39. entry: 'dist/tsbuild/index.js', // 入口文件
  40. name: '@fmode/server',
  41. fileName: (format) => `fmode.${format}.js`
  42. },
  43. rollupOptions: {
  44. input: 'dist/tsbuild/index.js', // 你的入口文件
  45. output: {
  46. dir: 'dist/vitebuild',
  47. format: 'cjs'
  48. }
  49. }
  50. }
  51. });