81 lines
2.3 KiB
JavaScript
81 lines
2.3 KiB
JavaScript
module.exports = {
|
||
// 添加应用标题配置
|
||
chainWebpack: (config) => {
|
||
config.plugin("html").tap((args) => {
|
||
args[0].title = "统计技能考试系统";
|
||
return args;
|
||
});
|
||
},
|
||
pluginOptions: {
|
||
electronBuilder: {
|
||
nodeIntegration: false,
|
||
contextIsolation: true,
|
||
preload: "src/preload.js",
|
||
mainProcessFile: "background/main.js",
|
||
lintPreloadFiles: false,
|
||
// 添加这段配置确保构建路径正确
|
||
outputDir: 'dist_electron',
|
||
// 将externals改为数组格式
|
||
externals: ["fontkit", "pdfkit"],
|
||
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");
|
||
},
|
||
// Windows 7便携应用配置 - 兼容Electron 11和electron-builder 22.9.1
|
||
win: {
|
||
target: [
|
||
{
|
||
target: "portable",
|
||
arch: ["ia32", "x64"],
|
||
},
|
||
],
|
||
icon: "public/favicon.ico",
|
||
// 在electron-builder 22.9.1中,compression选项应该在这里设置
|
||
// 删除了之前的错误配置
|
||
// 针对Windows 7的特殊配置
|
||
extraResources: [
|
||
{
|
||
from: "background/font", // 更新为新路径
|
||
to: "font",
|
||
filter: ["**/*"],
|
||
},
|
||
{
|
||
from: "data",
|
||
to: "data",
|
||
filter: [".gitignore"],
|
||
},
|
||
],
|
||
},
|
||
// 便携应用配置 - 兼容Electron 11
|
||
portable: {
|
||
artifactName: "统计技能考试系统_便携版_${version}_${arch}.exe",
|
||
// 启用便携模式标志
|
||
target: "portable",
|
||
},
|
||
// 在electron-builder 22.9.1中,压缩配置应该在build选项中设置
|
||
builderOptions: {
|
||
compression: "store", // 等同于--no-compress,不压缩应用
|
||
},
|
||
},
|
||
},
|
||
};
|