Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion _scripts/webpack.main.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path')
const webpack = require('webpack')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const JsonMinimizerPlugin = require('json-minimizer-webpack-plugin')

Expand Down Expand Up @@ -33,7 +34,11 @@ const config = {
__dirname: isDevMode,
__filename: isDevMode
},
plugins: [],
plugins: [
new webpack.DefinePlugin({
'process.env.IS_ELECTRON_MAIN': true
})
],
output: {
filename: '[name].js',
libraryTarget: 'commonjs2',
Expand Down
1 change: 1 addition & 0 deletions _scripts/webpack.renderer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const config = {
processLocalesPlugin,
new webpack.DefinePlugin({
'process.env.IS_ELECTRON': true,
'process.env.IS_ELECTRON_MAIN': false,
'process.env.LOCALE_NAMES': JSON.stringify(processLocalesPlugin.localeNames)
}),
new HtmlWebpackPlugin({
Expand Down
3 changes: 2 additions & 1 deletion _scripts/webpack.web.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ const config = {
},
plugins: [
new webpack.DefinePlugin({
'process.env.IS_ELECTRON': false
'process.env.IS_ELECTRON': false,
'process.env.IS_ELECTRON_MAIN': false
}),
new webpack.ProvidePlugin({
process: 'process/browser',
Expand Down
3 changes: 1 addition & 2 deletions src/datastores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import Datastore from 'nedb-promises'

let dbPath = null

const isElectronMain = !!process?.versions?.electron
if (isElectronMain) {
if (process.env.IS_ELECTRON_MAIN) {
const { app } = require('electron')
const { join } = require('path')
const userDataPath = app.getPath('userData') // This is based on the user's OS
Expand Down