Add AutoRobot directory with Windows line endings
This commit is contained in:
88
AutoRobot/Windows/Robot/Web/vite.config.js
Normal file
88
AutoRobot/Windows/Robot/Web/vite.config.js
Normal file
@@ -0,0 +1,88 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
|
||||
// 定义一个简单的插件来解决阿里云SDK加载问题
|
||||
const fixAliyunSDKPlugin = {
|
||||
name: 'fix-aliyun-sdk',
|
||||
enforce: 'pre',
|
||||
transform(code, id) {
|
||||
// 在构建时移除对阿里云安全SDK的引用
|
||||
// 这个正则会匹配可能的阿里云SDK引入代码
|
||||
if (code.includes('ice-plugin-spm') || code.includes('APlus') || code.includes('securitySDK')) {
|
||||
return code
|
||||
.replace(/import\s+.*ice-plugin-spm.*;/g, '')
|
||||
.replace(/import\s+.*APlus.*;/g, '')
|
||||
.replace(/import\s+.*securitySDK.*;/g, '')
|
||||
.replace(/\s*script\s*src\s*=\s*["']https:\/\/o\.alicdn\.com\/tbpc\/securitySDK\/securitySDK\.umd\.js["']\s*>/g, '')
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const isDebug = mode === 'debug'
|
||||
const isRelease = mode === 'release'
|
||||
|
||||
return {
|
||||
// 配置Vue插件以支持更好的调试体验
|
||||
plugins: [
|
||||
vue({
|
||||
template: {
|
||||
compilerOptions: {
|
||||
// 启用调试提示
|
||||
whitespace: 'preserve'
|
||||
}
|
||||
}
|
||||
}),
|
||||
fixAliyunSDKPlugin // 添加我们的修复插件
|
||||
],
|
||||
server: {
|
||||
port: 8080, // 改为不同于后端的端口
|
||||
proxy: {
|
||||
// 添加代理配置,将WebSocket请求转发到后端
|
||||
'/': {
|
||||
target: 'http://localhost:8805',
|
||||
ws: true,
|
||||
changeOrigin: true,
|
||||
// 配置代理超时时间,避免过早断开连接
|
||||
timeout: 60000,
|
||||
// 配置重写规则
|
||||
rewrite: (path) => path
|
||||
}
|
||||
}
|
||||
},
|
||||
// 根据模式配置构建选项
|
||||
build: {
|
||||
// 调试模式下启用sourcemap,发布模式下禁用
|
||||
sourcemap: isDebug,
|
||||
// 调试模式下禁用压缩,发布模式下启用
|
||||
minify: isRelease,
|
||||
// 根据模式设置不同的输出目录
|
||||
outDir: 'dist',
|
||||
// 配置外部依赖,避免打包不必要的库
|
||||
rollupOptions: {
|
||||
external: ['https://o.alicdn.com/tbpc/securitySDK/securitySDK.umd.js']
|
||||
}
|
||||
},
|
||||
// 配置CSS预处理器选项
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
css: {
|
||||
// 禁用@import内联,可能有助于解决一些导入问题
|
||||
url: false
|
||||
},
|
||||
// 配置Sass使用现代API,避免旧版JS API警告
|
||||
scss: {
|
||||
api: 'modern-compiler'
|
||||
},
|
||||
sass: {
|
||||
api: 'modern-compiler'
|
||||
}
|
||||
}
|
||||
},
|
||||
// 配置开发服务器的CSP头信息
|
||||
headers: {
|
||||
'Content-Security-Policy': "script-src 'self' 'unsafe-inline' 'unsafe-eval'"
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user