template-electron17-vue3/build.mjs

51 lines
1.6 KiB
JavaScript

import fs from 'fs';
import electronBuilder from 'electron-builder';
(async () => {
fs.rmdirSync('./build', { recursive: true });
await electronBuilder.build({
targets: {
'linux': electronBuilder.Platform.LINUX.createTarget(),
'win32': electronBuilder.Platform.WINDOWS.createTarget(),
'darwin': electronBuilder.Platform.MAC.createTarget()
}[process.platform],
config: {
files: fs
.readdirSync('.', { withFileTypes: true })
.filter(item => ![
'.git',
'.gitignore',
'build.mjs',
'config.example.js',
'start.mjs',
'yarn.lock',
...fs
.readFileSync('./.gitignore', 'utf8')
.split('\n')
.filter(item => !['node_modules', 'config.js'].includes(item))
].includes(item.name))
.map(item => `${item.name}${item.isDirectory() ? '/**' : ''}`),
directories: {
output: 'build',
buildResources: 'src-electron/assets'
},
win: {
target: [{
target: 'nsis',
arch: 'x64'
}],
},
linux: {
target: [{
target: 'AppImage',
arch: 'x64'
}],
},
mac: {
target: [{
target: 'dmg'
}]
}
}
});
})().catch(console.error);