antares/webpack.main.config.js

78 lines
1.9 KiB
JavaScript
Raw Normal View History

const path = require('path');
2022-02-17 18:47:50 +01:00
const webpack = require('webpack');
const ProgressPlugin = require('progress-webpack-plugin');
2022-02-17 18:47:50 +01:00
const { dependencies, devDependencies, version } = require('./package.json');
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'),
filename: '[name].js'
},
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')
},
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': {
PACKAGE_VERSION: `"${version}"`
}
2022-02-17 18:47:50 +01:00
})
],
module: {
rules: [
{
test: /\.node$/,
loader: 'node-loader',
options: {
name: '[path][name].[ext]'
}
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'
}]
}
]
}
2022-02-17 18:47:50 +01:00
};