import path from 'path' ; import webpack from 'webpack' ; const cwd = process . cwd ( ) ; const externals = require ( path . join ( cwd , 'package.json' ) ) . dependencies ; export default ( env ) : webpack . Configuration => ( { mode : env , target : 'electron-main' , node : { __dirname : false , __filename : false , } , externals : [ ... Object . keys ( externals || { } ) ] , devtool : 'source-map' , resolve : { extensions : [ '.js' , '.jsx' , '.json' , '.ts' , '.tsx' ] , modules : [ path . join ( cwd , 'app' ) , 'node_modules' ] , } , output : { libraryTarget : 'commonjs2' , } , module : { rules : [ { test : /\.(js|ts)x?$/ , use : { loader : 'babel-loader' , options : { cacheDirectory : true , presets : [ '@babel/preset-typescript' ] , } , } , exclude : [ /node_modules/ , path . join ( cwd , 'renderer' ) , ] , } , ] , } , plugins : [ new webpack . EnvironmentPlugin ( { NODE_ENV : env , } ) , ] , } ) ;