mirror of
https://github.com/heyman/heynote.git
synced 2024-11-28 10:54:22 +01:00
079fa666d6
* Move windows.darkMode -> window.heynote.themeMode * Only add UpdateStatusItem if window.heynote.autoUpdate is set * Update Vite * Implement web version of Heynote. Add a child vite project in ./webapp/ that is Heynote running within a browser. Imports almost all code from ../src/ and only adds a thin bridge that corresponds to the API between the Electron main process and the app code. * Remove commented out tag * Specify publicDir in vite config, instead of using a symlink * Add webapp_dev npm command to package.json * Add npm run command: webapp:build * Add resolve alias '@' that points to project root. Move assets file from public to assets in order to let Vite/Rollup handle bundling.
115 lines
2.9 KiB
TypeScript
115 lines
2.9 KiB
TypeScript
import { rmSync } from 'node:fs'
|
|
import { join } from 'node:path'
|
|
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import electron from 'vite-plugin-electron'
|
|
import renderer from 'vite-plugin-electron-renderer'
|
|
import license from 'rollup-plugin-license'
|
|
import pkg from './package.json'
|
|
import path from 'path'
|
|
|
|
rmSync('dist-electron', { recursive: true, force: true })
|
|
|
|
const isDevelopment = process.env.NODE_ENV === "development" || !!process.env.VSCODE_DEBUG
|
|
const isProduction = process.env.NODE_ENV === "production"
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname),
|
|
},
|
|
},
|
|
|
|
plugins: [
|
|
vue(),
|
|
electron([
|
|
{
|
|
// Main-Process entry file of the Electron App.
|
|
entry: 'electron/main/index.ts',
|
|
onstart(options) {
|
|
if (process.env.VSCODE_DEBUG) {
|
|
console.log(/* For `.vscode/.debug.script.mjs` */'[startup] Electron App')
|
|
} else {
|
|
options.startup()
|
|
}
|
|
},
|
|
vite: {
|
|
build: {
|
|
sourcemap: isDevelopment,
|
|
minify: isProduction,
|
|
outDir: 'dist-electron/main',
|
|
rollupOptions: {
|
|
external: Object.keys("dependencies" in pkg ? pkg.dependencies : {}),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
entry: 'electron/preload/index.ts',
|
|
onstart(options) {
|
|
// Notify the Renderer-Process to reload the page when the Preload-Scripts build is complete,
|
|
// instead of restarting the entire Electron App.
|
|
options.reload()
|
|
},
|
|
vite: {
|
|
build: {
|
|
sourcemap: isDevelopment,
|
|
minify: isProduction,
|
|
outDir: 'dist-electron/preload',
|
|
rollupOptions: {
|
|
external: Object.keys("dependencies" in pkg ? pkg.dependencies : {}),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
entry: 'electron/preload/about-preload.js',
|
|
onstart(options) {
|
|
// Notify the Renderer-Process to reload the page when the Preload-Scripts build is complete,
|
|
// instead of restarting the entire Electron App.
|
|
options.reload()
|
|
},
|
|
vite: {
|
|
build: {
|
|
sourcemap: isDevelopment,
|
|
minify: isProduction,
|
|
outDir: 'dist-electron/preload',
|
|
rollupOptions: {
|
|
external: Object.keys("dependencies" in pkg ? pkg.dependencies : {}),
|
|
},
|
|
},
|
|
},
|
|
}
|
|
]),
|
|
// Use Node.js API in the Renderer-process
|
|
renderer({
|
|
nodeIntegration: false, // turning this on will break Math.js
|
|
}),
|
|
|
|
// Add license header to the built files
|
|
license({thirdParty: {
|
|
output: join(__dirname, 'dist', 'dependencies.txt'),
|
|
includePrivate: true, // Default is false.
|
|
},
|
|
})
|
|
],
|
|
css: {
|
|
preprocessorOptions: {
|
|
sass: {
|
|
additionalData: `
|
|
@import "./src/css/include.sass"
|
|
`
|
|
}
|
|
}
|
|
},
|
|
server: !!process.env.VSCODE_DEBUG ? (() => {
|
|
const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
|
|
return {
|
|
host: url.hostname,
|
|
port: +url.port,
|
|
}
|
|
})() : undefined,
|
|
clearScreen: false,
|
|
})
|