2018-03-07 14:28:48 +01:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
process.env.BABEL_ENV = 'main'
|
|
|
|
|
|
|
|
const path = require('path')
|
|
|
|
const { dependencies } = require('../package.json')
|
|
|
|
const webpack = require('webpack')
|
|
|
|
|
2018-08-14 17:46:48 +02:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
2018-03-07 14:28:48 +01:00
|
|
|
|
|
|
|
let mainConfig = {
|
|
|
|
entry: {
|
2019-12-18 16:17:03 +01:00
|
|
|
main: path.join(__dirname, '../src/main/index.ts'),
|
|
|
|
preload: path.join(__dirname, '../src/main/preload.js')
|
2018-03-07 14:28:48 +01:00
|
|
|
},
|
2019-11-26 16:29:02 +01:00
|
|
|
externals: [...Object.keys(dependencies || {})],
|
2018-03-07 14:28:48 +01:00
|
|
|
module: {
|
|
|
|
rules: [
|
2019-03-20 16:07:21 +01:00
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
exclude: /node_modules/,
|
2022-08-13 18:37:20 +02:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'ts-loader',
|
|
|
|
options: {
|
|
|
|
transpileOnly: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2019-03-20 16:07:21 +01:00
|
|
|
},
|
2018-03-07 14:28:48 +01:00
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
use: 'babel-loader',
|
|
|
|
exclude: /node_modules/
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.node$/,
|
|
|
|
use: 'node-loader'
|
2019-11-26 16:29:02 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.json$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: 'json-loader',
|
|
|
|
type: 'javascript/auto'
|
2018-03-07 14:28:48 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
node: {
|
|
|
|
__dirname: process.env.NODE_ENV !== 'production',
|
|
|
|
__filename: process.env.NODE_ENV !== 'production'
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
filename: '[name].js',
|
|
|
|
libraryTarget: 'commonjs2',
|
|
|
|
path: path.join(__dirname, '../dist/electron')
|
|
|
|
},
|
|
|
|
plugins: [
|
2018-08-14 17:46:48 +02:00
|
|
|
new webpack.NoEmitOnErrorsPlugin(),
|
2020-05-27 17:45:42 +02:00
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: path.join(__dirname, '../src/config/locales'),
|
|
|
|
to: path.join(__dirname, '../dist/electron/locales'),
|
|
|
|
globOptions: {
|
|
|
|
ignore: ['.*', '*~']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
2018-03-07 14:28:48 +01:00
|
|
|
],
|
|
|
|
resolve: {
|
2019-04-16 15:35:46 +02:00
|
|
|
alias: {
|
|
|
|
// Same as tsconfig.json
|
|
|
|
'@': path.join(__dirname, '../src/renderer'),
|
|
|
|
'~': path.join(__dirname, '../')
|
|
|
|
},
|
2019-03-20 16:07:21 +01:00
|
|
|
extensions: ['.js', '.json', '.node', '.ts']
|
2018-03-07 14:28:48 +01:00
|
|
|
},
|
|
|
|
target: 'electron-main'
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adjust mainConfig for development settings
|
|
|
|
*/
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
mainConfig.plugins.push(
|
|
|
|
new webpack.DefinePlugin({
|
2019-11-26 16:29:02 +01:00
|
|
|
__static: `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
|
2018-03-07 14:28:48 +01:00
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adjust mainConfig for production settings
|
|
|
|
*/
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
2019-12-21 15:20:50 +01:00
|
|
|
mainConfig.mode = 'production'
|
2018-03-07 14:28:48 +01:00
|
|
|
mainConfig.plugins.push(
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.NODE_ENV': '"production"'
|
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = mainConfig
|