You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
55 lines
1.5 KiB
4 weeks ago
|
const path = require('path')
|
||
|
const { defineConfig } = require('@vue/cli-service')
|
||
|
|
||
|
module.exports = defineConfig({
|
||
|
outputDir: path.resolve(__dirname, 'dist/renderer'),
|
||
|
publicPath: './',
|
||
|
|
||
|
// 关键修改:配置 Electron 构建目标和排除原生模块
|
||
|
configureWebpack: {
|
||
|
target: 'electron-renderer', // 指定为 Electron 渲染进程
|
||
|
externals: {
|
||
|
electron: 'require("electron")', // 防止 Webpack 处理 electron 模块
|
||
|
fs: 'require("fs")', // 排除 Node.js 原生模块
|
||
|
path: 'require("path")',
|
||
|
},
|
||
|
resolve: {
|
||
|
alias: {
|
||
|
'@': path.resolve(__dirname, 'src/renderer'),
|
||
|
// 确保 Vue 单文件组件引用时自动补全扩展名
|
||
|
'views': path.resolve(__dirname, 'src/renderer/views')
|
||
|
},
|
||
|
// 添加扩展名自动解析
|
||
|
extensions: ['.js', '.vue', '.json']
|
||
|
}
|
||
|
},
|
||
|
|
||
|
// 保留原有页面配置
|
||
|
pages: {
|
||
|
index: {
|
||
|
entry: 'src/renderer/main.js',
|
||
|
template: 'public/index.html',
|
||
|
filename: 'index.html'
|
||
|
}
|
||
|
},
|
||
|
|
||
|
// 保留 Electron Builder 配置
|
||
|
pluginOptions: {
|
||
|
electronBuilder: {
|
||
|
preload: 'src/preload.js',
|
||
|
nodeIntegration: false,
|
||
|
contextIsolation: true,
|
||
|
// 可选:明确指定主进程文件路径
|
||
|
mainProcessFile: 'src/main/index.js'
|
||
|
}
|
||
|
},
|
||
|
|
||
|
// 开发服务器配置(与 Electron 主进程配合)
|
||
|
devServer: {
|
||
|
port: 8080, // 确保与 wait-on 端口一致
|
||
|
hot: true,
|
||
|
headers: {
|
||
|
'Access-Control-Allow-Origin': '*'
|
||
|
}
|
||
|
}
|
||
|
})
|