exam11/vue.config.js
2025-09-09 11:29:14 +08:00

121 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module.exports = {
// 添加应用标题配置
chainWebpack: (config) => {
config.plugin("html").tap((args) => {
args[0].title = "统计技能考试系统";
return args;
});
},
// 将outputDir移到顶层配置
outputDir: 'dist_electron',
pluginOptions: {
electronBuilder: {
nodeIntegration: false,
contextIsolation: true,
preload: "src/preload.js",
mainProcessFile: "background/main.js",
lintPreloadFiles: false,
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", // 包含整个background目录
to: "background",
filter: ["**/*"],
},
{
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",
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: "portable",
},
},
},
},
};