mirror of https://github.com/FreeTubeApp/FreeTube
Add an IS_ELECTRON_MAIN define instead of runtime detection (#3056)
This commit is contained in:
parent
c1462dc3d1
commit
7becd36120
|
@ -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')
|
||||
|
||||
|
@ -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',
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue