import { defineConfig } from 'vite'; import obfuscatorPlugin from 'vite-plugin-javascript-obfuscator'; import { VitePluginNode } from 'vite-plugin-node'; export default defineConfig({ server:{ port:61337 }, plugins: [ VitePluginNode({ adapter:"express", appPath:"./server.js", exportName:"EduTextbookServer", // initAppOnBoot:false, }), obfuscatorPlugin({ include: ["**/*.js"], exclude: [/node_modules/], apply: "build", debugger: true, options: { debugProtection:false, debugProtectionInterval:0, // ... [See more options](https://github.com/javascript-obfuscator/javascript-obfuscator) compact: true, controlFlowFlattening: false, controlFlowFlatteningThreshold: 0.5, deadCodeInjection: false, deadCodeInjectionThreshold: 0.2, disableConsoleOutput: false, // 禁用日志输出,调试时关闭 identifierNamesGenerator: 'hexadecimal', log: true, renameGlobals: false, rotateStringArray: true, selfDefending: false, stringArray: true, stringArrayEncoding: ['base64'], stringArrayThreshold: 0.5, transformObjectKeys: false, unicodeEscapeSequence: false }, }), ], build: { lib: { entry: 'server.js', // 入口文件 name: 'edu-textbook-server', fileName: (format) => `edu-textbook-server.${format}.js` }, rollupOptions: { input: 'server.js', // 你的入口文件 output: { dir: 'dist/server', format: 'cjs' } } } });