This commit is contained in:
2021-03-14 19:06:51 +01:00
parent de211eb1d3
commit 560b0f4c74
43 changed files with 5944 additions and 175 deletions

8
config/.eslintrc.js Normal file
View File

@@ -0,0 +1,8 @@
module.exports = {
env: {
node: true,
},
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
};

View File

@@ -0,0 +1,11 @@
/**
* @type {import('electron-builder').Configuration}
* @see https://www.electron.build/configuration/configuration
*/
module.exports = {
directories: {
output: 'dist/app',
buildResources: 'build',
app: 'dist/source',
},
};

View File

@@ -0,0 +1,4 @@
module.exports = {
chrome: 85,
node: 12,
};

View File

@@ -0,0 +1,59 @@
/**
By default, vite optimizes and packs all the necessary dependencies into your bundle,
so there is no need to supply them in your application as a node module.
Unfortunately, vite cannot optimize any dependencies:
Some that are designed for a node environment may not work correctly after optimization.
Therefore, such dependencies should be marked as "external":
they will not be optimized, will not be included in your bundle, and will be delivered as a separate node module.
*/
module.exports.external = [
'electron',
'electron-updater',
];
module.exports.builtins = [
'assert',
'async_hooks',
'buffer',
'child_process',
'cluster',
'console',
'constants',
'crypto',
'dgram',
'dns',
'domain',
'events',
'fs',
'http',
'http2',
'https',
'inspector',
'module',
'net',
'os',
'path',
'perf_hooks',
'process',
'punycode',
'querystring',
'readline',
'repl',
'stream',
'string_decoder',
'timers',
'tls',
'trace_events',
'tty',
'url',
'util',
'v8',
'vm',
'zlib',
];
module.exports.default = [
...module.exports.builtins,
...module.exports.external,
];

37
config/main.vite.js Normal file
View File

@@ -0,0 +1,37 @@
const {node} = require('./electron-vendors');
const {join} = require('path');
/**
* @type {import('vite').UserConfig}
* @see https://vitejs.dev/config/
*/
module.exports = () => {
return {
resolve: {
alias: {
'/@/': join(process.cwd(), './src/main') + '/',
},
},
build: {
sourcemap: 'inline',
target: `node${node}`,
outDir: 'dist/source/main',
assetsDir: '.',
minify: process.env.MODE === 'development' ? false : 'terser',
lib: {
entry: 'src/main/index.ts',
formats: ['cjs'],
},
rollupOptions: {
external: require('./external-packages').default,
output: {
entryFileNames: '[name].[format].js',
chunkFileNames: '[name].[format].js',
assetFileNames: '[name].[ext]',
},
},
emptyOutDir: true,
},
};
};

34
config/preload.vite.js Normal file
View File

@@ -0,0 +1,34 @@
const {chrome} = require('./electron-vendors');
const {join} = require('path');
/**
* @type {import('vite').UserConfig}
* @see https://vitejs.dev/config/
*/
module.exports = {
resolve: {
alias: {
'/@/': join(process.cwd(), './src/preload') + '/',
},
},
build: {
sourcemap: 'inline',
target: `chrome${chrome}`,
outDir: 'dist/source/preload',
assetsDir: '.',
minify: process.env.MODE === 'development' ? false : 'terser',
lib: {
entry: 'src/preload/index.ts',
formats: ['cjs'],
},
rollupOptions: {
external: require('./external-packages').default,
output: {
entryFileNames: '[name].[format].js',
chunkFileNames: '[name].[format].js',
assetFileNames: '[name].[ext]',
},
},
emptyOutDir: true,
},
};

29
config/renderer.vite.js Normal file
View File

@@ -0,0 +1,29 @@
const {join} = require('path');
const vue = require('@vitejs/plugin-vue');
const {chrome} = require('./electron-vendors');
/**
* @type {import('vite').UserConfig}
* @see https://vitejs.dev/config/
*/
module.exports = {
root: join(process.cwd(), './src/renderer'),
resolve: {
alias: {
'/@/': join(process.cwd(), './src/renderer') + '/',
},
},
plugins: [vue()],
base: '',
build: {
sourcemap: 'inline',
target: `chrome${chrome}`,
polyfillDynamicImport: false,
outDir: join(process.cwd(), 'dist/source/renderer'),
assetsDir: '.',
rollupOptions: {
external: require('./external-packages').default,
},
emptyOutDir: true,
},
};

18
config/tsconfig-base.json Normal file
View File

@@ -0,0 +1,18 @@
{
"compilerOptions": {
"module": "esnext",
"target": "esnext",
"sourceMap": true,
"moduleResolution": "Node",
"skipLibCheck": true,
"strict": true,
"isolatedModules": true,
"types": [
"../types/env",
"vite/client"
]
},
"exclude": [
"../**/node_modules"
]
}