'electron-packager' -> 'electron-builder'

This commit is contained in:
KaKi87 2021-10-01 17:08:35 +02:00
parent 4981fb1a9b
commit bb28f78e15
4 changed files with 986 additions and 398 deletions

View File

@ -1,40 +1,63 @@
const
fs = require('fs'),
Parcel = require('parcel-bundler'),
electronPackager = require('electron-packager'),
electronBuilder = require('electron-builder'),
{
icon,
name
} = require('./package.json'),
{
icon, // TODO
build: {
ignoredDirectories,
platforms
ignoredDirectories
}
} = require('./config.json');
const options = {
icon,
dir: __dirname,
arch: 'x64',
ignore: [
'.gitignore',
'build.js',
'README.md',
'yarn.lock',
...ignoredDirectories,
...fs.readFileSync('./.gitignore', 'utf8')
.split('\n')
.filter(path => !['dist', 'node_modules'].includes(path))
].map(item => '^/' + item),
out: 'build',
asar: true,
overwrite: true
};
(async () => {
fs.rmdirSync('./dist', { recursive: true });
await new Parcel('index.html', { publicURL: '.' }).bundle();
await Promise.all(platforms.map(platform => electronPackager({
...options,
platform
})));
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.js',
'README.md',
'yarn.lock',
...fs.readFileSync('./.gitignore', 'utf8')
.split('\n')
.filter(path => !['dist', 'node_modules'].includes(path))
].includes(item.name))
.map(item => `${item.name}${item.isDirectory() ? '/**' : ''}`),
directories: {
output: 'build'
},
win: {
target: [{
target: 'appx',
arch: 'x64'
}],
},
appx: {
applicationId: name.split('-').map(substring => `${substring[0].toUpperCase()}${substring.slice(1, substring.length).toLowerCase()}`).join('')
},
linux: {
target: [{
target: 'AppImage',
arch: 'x64'
}],
},
mac: {
target: [{
target: 'dmg'
}]
}
}
});
process.exit();
})();

View File

@ -4,7 +4,6 @@
"enableTitleBar": false,
"enableMenuBar": false,
"build": {
"ignoredDirectories": ["docs"],
"platforms": ["linux"]
"ignoredDirectories": ["docs"]
}
}

View File

@ -6,15 +6,15 @@
"build": "node ./build.js"
},
"dependencies": {
"electron": "^12.0.0",
"electron-packager": "^15.2.0",
"electron-store": "^7.0.2",
"parcel-bundler": "^1.12.4",
"vue": "^2.6.12",
"vue-hot-reload-api": "^2.3.4"
},
"devDependencies": {
"@vue/component-compiler-utils": "^3.2.0",
"electron": "^12.0.0",
"electron-builder": "^22.11.7",
"parcel-bundler": "^1.12.4",
"vue-template-compiler": "^2.6.12"
},
"browserslist": [

1298
yarn.lock

File diff suppressed because it is too large Load Diff