import { defineConfig } from 'umi' ; import { resolve } from 'path' ; import { readJSONSync } from 'fs-extra' ; import { srcPath , isDev } from './utils' ; import routes from './routes' ; import ElectronBuilderOpts from './electronBuilderOpts' ; const pkg = readJSONSync ( resolve ( srcPath , '../package.json' ) ) ; const deps = pkg . dependencies ; const externals = Object . keys ( deps ) ; export default defineConfig ( { nodeModulesTransform : { type : 'none' , } , see https scripts : isDev ? [ 'http://localhost:8097' ] : undefined , routes , /**
     * electron 默认情况下应该其实就是 mpa 环境
     * 但是直接使用 umi 的 mpa 方法会丢失全局 Layout
     * 因此使用 exportStatic 间接实现 mpa
     */ exportStatic : isDev ? undefined : { htmlSuffix : true , dynamicRoot : true , } , outputPath : '../../release' , electronBuilder : { buildType : 'webpack' , rendererTarget : 'electron-renderer' , routerMode : isDev ? 'hash' : 'browser' , outputDir : 'release' , builderOptions : ElectronBuilderOpts , externals , } , alias : { '@/common' : resolve ( srcPath , './common' ) , '@/bridge' : resolve ( srcPath , './renderer/bridge' ) , theme : resolve ( srcPath , './renderer/theme' ) , } , } ) ;