forge.config.ts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import type { ForgeConfig } from '@electron-forge/shared-types'
  2. import { MakerSquirrel } from '@electron-forge/maker-squirrel'
  3. import { MakerZIP } from '@electron-forge/maker-zip'
  4. import { PublisherGithub } from '@electron-forge/publisher-github'
  5. import { AutoUnpackNativesPlugin } from '@electron-forge/plugin-auto-unpack-natives'
  6. import { WebpackPlugin } from '@electron-forge/plugin-webpack'
  7. import * as path from 'path'
  8. import * as fs from 'fs'
  9. import { mainConfig } from './webpack.main.config'
  10. import { rendererConfig } from './webpack.renderer.config'
  11. const packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, './package.json'), 'utf8'))
  12. const config: ForgeConfig = {
  13. packagerConfig: {
  14. appVersion: process.env.VERSION || packageJson.version,
  15. asar: true,
  16. icon: './assets/icon.icns',
  17. extraResource: [
  18. '../dist/ollama',
  19. path.join(__dirname, './assets/iconTemplate.png'),
  20. path.join(__dirname, './assets/iconTemplate@2x.png'),
  21. path.join(__dirname, './assets/iconUpdateTemplate.png'),
  22. path.join(__dirname, './assets/iconUpdateTemplate@2x.png'),
  23. path.join(__dirname, './assets/iconDarkTemplate.png'),
  24. path.join(__dirname, './assets/iconDarkTemplate@2x.png'),
  25. path.join(__dirname, './assets/iconDarkUpdateTemplate.png'),
  26. path.join(__dirname, './assets/iconDarkUpdateTemplate@2x.png'),
  27. ],
  28. ...(process.env.SIGN
  29. ? {
  30. osxSign: {
  31. identity: process.env.APPLE_IDENTITY,
  32. },
  33. osxNotarize: {
  34. tool: 'notarytool',
  35. appleId: process.env.APPLE_ID || '',
  36. appleIdPassword: process.env.APPLE_PASSWORD || '',
  37. teamId: process.env.APPLE_TEAM_ID || '',
  38. },
  39. }
  40. : {}),
  41. osxUniversal: {
  42. x64ArchFiles: '**/ollama',
  43. },
  44. },
  45. rebuildConfig: {},
  46. makers: [new MakerSquirrel({}), new MakerZIP({}, ['darwin'])],
  47. hooks: {
  48. readPackageJson: async (_, packageJson) => {
  49. return { ...packageJson, version: process.env.VERSION || packageJson.version }
  50. },
  51. },
  52. plugins: [
  53. new AutoUnpackNativesPlugin({}),
  54. new WebpackPlugin({
  55. mainConfig,
  56. devContentSecurityPolicy: `default-src * 'unsafe-eval' 'unsafe-inline'; img-src data: 'self'`,
  57. renderer: {
  58. config: rendererConfig,
  59. nodeIntegration: true,
  60. entryPoints: [
  61. {
  62. html: './src/index.html',
  63. js: './src/renderer.tsx',
  64. name: 'main_window',
  65. preload: {
  66. js: './src/preload.ts',
  67. },
  68. },
  69. ],
  70. },
  71. }),
  72. ],
  73. }
  74. export default config