Add build script

This commit is contained in:
KaKi87 2022-02-08 20:31:28 +01:00
parent 399deef915
commit 8428a6c31e
4 changed files with 1092 additions and 18 deletions

3
.gitignore vendored
View File

@ -2,4 +2,5 @@
node_modules
config.js
.parcel-cache
dist
dist
build

58
build.mjs Normal file
View File

@ -0,0 +1,58 @@
import fs from 'fs';
import { Parcel } from '@parcel/core';
import electronBuilder from 'electron-builder';
(async () => {
fs.rmdirSync('./dist', { recursive: true });
fs.rmdirSync('./build', { recursive: true });
await new Parcel({
entries: 'src/index.html',
defaultConfig: '@parcel/config-default',
env: { NODE_ENV: 'production' }
}).run();
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 => !['dist', 'node_modules', 'config.js'].includes(item))
].includes(item.name))
.map(item => `${item.name}${item.isDirectory() ? '/**' : ''}`),
directories: {
output: 'build',
buildResources: 'assets'
},
win: {
target: [{
target: 'nsis',
arch: 'x64'
}],
},
linux: {
target: [{
target: 'AppImage',
arch: 'x64'
}],
},
mac: {
target: [{
target: 'dmg'
}]
}
}
});
})().catch(console.error);

View File

@ -10,11 +10,13 @@
"@parcel/core": "^2.2.1",
"@parcel/transformer-vue": "^2.2.1",
"electron": "^17.0.0",
"electron-builder": "^22.14.13",
"electron-devtools-installer": "^3.2.0",
"parcel": "^2.2.1"
},
"scripts": {
"start": "node ./start.mjs"
"start": "node ./start.mjs",
"build": "node ./build.mjs"
},
"dependencies": {
"destyle.css": "^3.0.2",

1045
yarn.lock

File diff suppressed because it is too large Load Diff