module.exports = { // 添加应用标题配置 chainWebpack: (config) => { config.plugin("html").tap((args) => { args[0].title = "统计技能考试系统"; return args; }); }, // 输出目录 outputDir: 'dist_electron', pluginOptions: { electronBuilder: { // 基础配置 nodeIntegration: false, contextIsolation: true, preload: "src/preload.js", mainProcessFile: "background/main.js", lintPreloadFiles: false, externals: ["fontkit", "pdfkit"], // 主进程webpack配置 chainWebpackMainProcess: (config) => { config.module .rule("babel") .test(/\.js$/) .use("babel-loader") .loader("babel-loader") .options({ presets: ["@babel/preset-env"], plugins: [ "@babel/plugin-proposal-optional-chaining", "@babel/plugin-proposal-class-properties", ], }) .end(); // 添加对mjs文件的处理 - 兼容Electron 11 config.module .rule("mjs") .test(/\.mjs$/) .include.add(/node_modules/) .end() .type("javascript/auto"); }, // 所有构建选项都放在这里 builderOptions: { // 应用基本信息 appId: 'com.example.exam11', productName: '统计技能考试系统', // 压缩设置 compression: "store", // 入口文件配置 extraMetadata: { main: "background.js" }, // Windows构建配置 win: { // 架构设置 target: [ { target: "portable", arch: ["ia32", "x64"], }, ], // 图标设置 icon: "public/favicon.ico", // 签名设置 signingHashAlgorithms: ['sha256'], sign: false, // 明确禁用签名 // 额外资源配置 extraResources: [ { from: "background", to: "background", filter: ["**/*"], }, { from: "background/font", to: "font", filter: ["**/*"], }, { from: "data", to: "data", filter: [".gitignore"], }, ], }, // 便携应用特定配置 portable: { artifactName: "统计技能考试系统_便携版_${version}_${arch}.exe", // 只保留支持的属性,移除target属性 }, // 发布设置 publish: { provider: 'generic', url: 'https://example.com/', } }, }, }, };