2021-10-31 10:36:45 +01:00
|
|
|
const path = require('path');
|
2022-02-17 18:47:50 +01:00
|
|
|
const webpack = require('webpack');
|
2021-10-31 10:36:45 +01:00
|
|
|
const ProgressPlugin = require('progress-webpack-plugin');
|
|
|
|
|
2022-02-17 18:47:50 +01:00
|
|
|
const { dependencies, devDependencies, version } = require('./package.json');
|
2021-10-31 10:36:45 +01:00
|
|
|
|
|
|
|
const externals = Object.keys(dependencies).concat(Object.keys(devDependencies));
|
|
|
|
const isDevMode = process.env.NODE_ENV === 'development';
|
|
|
|
const whiteListedModules = [];
|
|
|
|
|
2022-02-17 18:47:50 +01:00
|
|
|
module.exports = { // Main
|
|
|
|
name: 'main',
|
|
|
|
mode: process.env.NODE_ENV,
|
|
|
|
devtool: isDevMode ? 'eval-source-map' : false,
|
|
|
|
entry: {
|
2022-04-12 17:04:11 +02:00
|
|
|
main: path.join(__dirname, './src/main/main.ts')
|
2022-02-17 18:47:50 +01:00
|
|
|
},
|
|
|
|
target: 'electron-main',
|
|
|
|
output: {
|
|
|
|
libraryTarget: 'commonjs2',
|
|
|
|
path: path.join(__dirname, 'dist'),
|
2023-12-02 11:21:48 +01:00
|
|
|
filename: '[name].js',
|
|
|
|
assetModuleFilename: (pathData) => {
|
|
|
|
const { filename } = pathData;
|
|
|
|
|
|
|
|
if (filename.endsWith('.ts'))
|
|
|
|
return '[name].js';
|
|
|
|
else
|
|
|
|
return '[name][ext]';
|
|
|
|
}
|
2022-02-17 18:47:50 +01:00
|
|
|
},
|
|
|
|
node: {
|
|
|
|
global: true,
|
|
|
|
__dirname: isDevMode,
|
|
|
|
__filename: isDevMode
|
|
|
|
},
|
|
|
|
externals: externals.filter((d) => !whiteListedModules.includes(d)),
|
|
|
|
resolve: {
|
2022-04-12 17:04:11 +02:00
|
|
|
extensions: ['.js', '.json', '.ts'],
|
2022-02-17 18:47:50 +01:00
|
|
|
alias: {
|
|
|
|
src: path.join(__dirname, 'src/'),
|
|
|
|
common: path.resolve(__dirname, 'src/common')
|
2021-10-31 10:36:45 +01:00
|
|
|
},
|
2022-02-17 18:47:50 +01:00
|
|
|
fallback: {
|
|
|
|
'pg-native': false,
|
|
|
|
'cpu-features': false,
|
|
|
|
cardinal: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new ProgressPlugin(true),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {
|
2023-11-27 18:35:56 +01:00
|
|
|
PACKAGE_VERSION: `"${version}"`,
|
|
|
|
DISTRIBUTION: `"${process.env.DISTRIBUTION || 'none'}"`
|
2021-10-31 10:36:45 +01:00
|
|
|
}
|
2022-02-17 18:47:50 +01:00
|
|
|
})
|
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.node$/,
|
|
|
|
loader: 'node-loader',
|
|
|
|
options: {
|
|
|
|
name: '[path][name].[ext]'
|
2021-10-31 10:36:45 +01:00
|
|
|
}
|
2022-02-17 18:47:50 +01:00
|
|
|
},
|
2022-04-12 17:04:11 +02:00
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
loader: 'ts-loader'
|
|
|
|
},
|
2022-02-17 18:47:50 +01:00
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
loader: 'babel-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|jpg|gif)$/,
|
|
|
|
use: [{
|
|
|
|
loader: 'file-loader'
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
]
|
2021-10-31 10:36:45 +01:00
|
|
|
}
|
2022-02-17 18:47:50 +01:00
|
|
|
};
|