import * as path from "path" ; import { BannerPlugin , DefinePlugin } from "webpack" ; import { WebpackConfigurator } from "../main" ; import { getFirstExistingFile } from "../util" ; import { BaseTarget , configureFileLoader } from "./BaseTarget" ; export class MainTarget extends BaseTarget { constructor ( ) { super ( ) ; } configureRules ( configurator ) { super . configureRules ( configurator ) ; configurator . rules . push ( { test : /\.(png|jpg|gif)$/ , use : [ { loader : "url-loader" , options : configureFileLoader ( "imgs" , 10 * 1024 * 1024 ) , } ] } ) ; } async configurePlugins ( configurator ) { await BaseTarget . prototype . configurePlugins . call ( this , configurator ) ; if ( configurator . isProduction ) { configurator . plugins . push ( new DefinePlugin ( { __static : `process.resourcesPath + "/${ configurator . staticSourceDirectory }"` } ) ) ; configurator . plugins . push ( new BannerPlugin ( { banner : 'require("source-map-support/source-map-support.js").install();' , test : /\.js$/ , raw : true , entryOnly : true , } ) ) ; return ; } configurator . entryFiles . push ( path . join ( __dirname , "../electron-main-hmr/main-hmr" ) ) ; const devIndexFile = await getFirstExistingFile ( [ "index.dev.ts" , "index.dev.js" ] , path . join ( configurator . projectDir , "src/main" ) ) ; if ( devIndexFile != null ) { configurator . entryFiles . push ( devIndexFile ) ; } } }