77 lines
2.5 KiB
TypeScript
77 lines
2.5 KiB
TypeScript
import { createPublicKey } from 'crypto'
|
|
import { readFileSync } from 'fs'
|
|
import { resolve } from 'path'
|
|
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
const sharedAlias = {
|
|
'@d3ro/core': resolve(__dirname, '../../packages/core/src'),
|
|
'@d3ro/ui': resolve(__dirname, '../../packages/ui/src'),
|
|
'@d3ro/i18n': resolve(__dirname, '../../packages/i18n/src/index.tsx')
|
|
}
|
|
|
|
const workspaceExclude = ['@d3ro/core', '@d3ro/ui', '@d3ro/i18n']
|
|
const licensePublicKeyPath = resolve(__dirname, 'resources/license/production-public.pem')
|
|
const licensePublicKey = readFileSync(licensePublicKeyPath, 'utf8').trim()
|
|
const parsedLicensePublicKey = createPublicKey(licensePublicKey)
|
|
if (parsedLicensePublicKey.asymmetricKeyType !== 'ed25519') {
|
|
throw new Error(`Desktop license public key must be Ed25519: ${licensePublicKeyPath}`)
|
|
}
|
|
|
|
export default defineConfig({
|
|
main: {
|
|
// 공개키만 main bundle에 주입한다. 대응 ADMIN_LICENSE_PRIVATE_KEY는 admin 서버 전용이다.
|
|
define: {
|
|
'process.env.D3RO_LICENSE_PUBLIC_KEY': JSON.stringify(licensePublicKey)
|
|
},
|
|
plugins: [
|
|
externalizeDepsPlugin({
|
|
exclude: ['electron-store', ...workspaceExclude]
|
|
})
|
|
],
|
|
resolve: { alias: sharedAlias }
|
|
},
|
|
preload: {
|
|
plugins: [externalizeDepsPlugin({ exclude: workspaceExclude })],
|
|
build: {
|
|
rollupOptions: {
|
|
input: {
|
|
index: resolve(__dirname, 'src/preload/index.ts'),
|
|
popup: resolve(__dirname, 'src/preload/popup.ts')
|
|
}
|
|
}
|
|
},
|
|
resolve: { alias: sharedAlias }
|
|
},
|
|
renderer: {
|
|
build: {
|
|
rollupOptions: {
|
|
input: {
|
|
index: resolve(__dirname, 'src/renderer/index.html'),
|
|
'popups/recording-tip': resolve(
|
|
__dirname,
|
|
'src/renderer/popups/recording-tip/index.html'
|
|
),
|
|
'popups/result-popup': resolve(
|
|
__dirname,
|
|
'src/renderer/popups/result-popup/index.html'
|
|
),
|
|
'popups/history-popup': resolve(
|
|
__dirname,
|
|
'src/renderer/popups/history-popup/index.html'
|
|
),
|
|
'popups/command-popup': resolve(
|
|
__dirname,
|
|
'src/renderer/popups/command-popup/index.html'
|
|
),
|
|
'popups/caption-overlay': resolve(
|
|
__dirname,
|
|
'src/renderer/popups/caption-overlay/index.html'
|
|
)
|
|
}
|
|
}
|
|
},
|
|
resolve: { alias: sharedAlias },
|
|
plugins: [react()]
|
|
}
|
|
})
|