vite 项目混淆加密 怎么配置?下面这样配置会报错caught TypeError: Failed to resolve module specifier "vue". Relative references must start with either "/", "./", or "../".
想要只在生产环境build添加加密,应该怎么写呢?
build: {
rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
external: ['vue', 'jquery'],
output: {
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
globals: {
vue: 'Vue',
jquery: '$'
}
},
plugins: [
obfuscator({
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
deadCodeInjection: true,
deadCodeInjectionThreshold: 1,
debugProtection: true,
debugProtectionInterval: 0,
disableConsoleOutput: true,
identifierNamesGenerator: "hexadecimal",
log: false,
renameGlobals: false,
rotateStringArray: true,
selfDefending: true,
shuffleStringArray: true,
splitStrings: true,
splitStringsChunkLength: 10,
stringArray: true,
stringArrayEncoding: ["rc4"],
stringArrayThreshold: 1,
transformObjectKeys: true,
unicodeEscapeSequence: false,
}),
],
},
},