const path = require('path'); const nodeExternals = require('webpack-node-externals'); const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); const mode = process.env.NODE_ENV || 'development'; const webpack = require('webpack'); module.exports = { mode, entry: { main: './src/main.ts', preload: './src/preload.ts', }, target: 'electron-main', externals: [nodeExternals()], module: { rules: [ { test: /\.ts$/, include: /src/, use: [{ loader: 'ts-loader' }] }, { test: /\.node$/, use: 'node-loader' } ] }, resolve: { extensions: ['.ts', '.js'], plugins: [new TsconfigPathsPlugin({ configFile: './tsconfig.json' })] }, plugins: [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || mode) }) ], output: { path: path.resolve(__dirname, 'build'), filename: '[name].js' }, node: { __dirname: false, __filename: false } }