mirror of https://github.com/FreeTubeApp/FreeTube
Allow webpack to omit development only dependencies properly (#2828)
This commit is contained in:
parent
7a2d4ade43
commit
56416700bc
|
@ -156,12 +156,6 @@ if (!isDevMode) {
|
||||||
processLocalesPlugin,
|
processLocalesPlugin,
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env.LOCALE_NAMES': JSON.stringify(processLocalesPlugin.localeNames)
|
'process.env.LOCALE_NAMES': JSON.stringify(processLocalesPlugin.localeNames)
|
||||||
}),
|
|
||||||
// webpack doesn't get rid of js-yaml even though it isn't used in the production builds
|
|
||||||
// so we need to manually tell it to ignore any imports for `js-yaml`
|
|
||||||
new webpack.IgnorePlugin({
|
|
||||||
resourceRegExp: /^js-yaml$/,
|
|
||||||
contextRegExp: /i18n$/
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,12 +189,6 @@ config.plugins.push(
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}),
|
|
||||||
// webpack doesn't get rid of js-yaml even though it isn't used in the production builds
|
|
||||||
// so we need to manually tell it to ignore any imports for `js-yaml`
|
|
||||||
new webpack.IgnorePlugin({
|
|
||||||
resourceRegExp: /^js-yaml$/,
|
|
||||||
contextRegExp: /i18n$/
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ function runApp() {
|
||||||
|
|
||||||
// disable electron warning
|
// disable electron warning
|
||||||
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true'
|
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true'
|
||||||
const isDev = process.env.NODE_ENV === 'development'
|
|
||||||
const isDebug = process.argv.includes('--debug')
|
const isDebug = process.argv.includes('--debug')
|
||||||
|
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
@ -67,7 +66,7 @@ function runApp() {
|
||||||
app.removeAsDefaultProtocolClient('freetube')
|
app.removeAsDefaultProtocolClient('freetube')
|
||||||
|
|
||||||
// If we are running a non-packaged version of the app && on windows
|
// If we are running a non-packaged version of the app && on windows
|
||||||
if (isDev && process.platform === 'win32') {
|
if (process.env.NODE_ENV === 'development' && process.platform === 'win32') {
|
||||||
// Set the path of electron.exe and your app.
|
// Set the path of electron.exe and your app.
|
||||||
// These two additional parameters are only available on windows.
|
// These two additional parameters are only available on windows.
|
||||||
app.setAsDefaultProtocolClient('freetube', process.execPath, [path.resolve(process.argv[1])])
|
app.setAsDefaultProtocolClient('freetube', process.execPath, [path.resolve(process.argv[1])])
|
||||||
|
@ -75,7 +74,7 @@ function runApp() {
|
||||||
app.setAsDefaultProtocolClient('freetube')
|
app.setAsDefaultProtocolClient('freetube')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDev) {
|
if (process.env.NODE_ENV !== 'development') {
|
||||||
// Only allow single instance of the application
|
// Only allow single instance of the application
|
||||||
const gotTheLock = app.requestSingleInstanceLock()
|
const gotTheLock = app.requestSingleInstanceLock()
|
||||||
if (!gotTheLock) {
|
if (!gotTheLock) {
|
||||||
|
@ -271,7 +270,7 @@ function runApp() {
|
||||||
|
|
||||||
await createWindow()
|
await createWindow()
|
||||||
|
|
||||||
if (isDev) {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
installDevTools()
|
installDevTools()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +325,7 @@ function runApp() {
|
||||||
const commonBrowserWindowOptions = {
|
const commonBrowserWindowOptions = {
|
||||||
backgroundColor: windowBackground,
|
backgroundColor: windowBackground,
|
||||||
darkTheme: nativeTheme.shouldUseDarkColors,
|
darkTheme: nativeTheme.shouldUseDarkColors,
|
||||||
icon: isDev
|
icon: process.env.NODE_ENV === 'development'
|
||||||
? path.join(__dirname, '../../_icons/iconColor.png')
|
? path.join(__dirname, '../../_icons/iconColor.png')
|
||||||
/* eslint-disable-next-line */
|
/* eslint-disable-next-line */
|
||||||
: `${__dirname}/_icons/iconColor.png`,
|
: `${__dirname}/_icons/iconColor.png`,
|
||||||
|
@ -409,7 +408,7 @@ function runApp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// load root file/url
|
// load root file/url
|
||||||
if (isDev) {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
let devStartupURL = 'http://localhost:9080'
|
let devStartupURL = 'http://localhost:9080'
|
||||||
if (windowStartupUrl != null) {
|
if (windowStartupUrl != null) {
|
||||||
devStartupURL = windowStartupUrl
|
devStartupURL = windowStartupUrl
|
||||||
|
@ -434,7 +433,7 @@ function runApp() {
|
||||||
newWindow.once('ready-to-show', () => {
|
newWindow.once('ready-to-show', () => {
|
||||||
if (newWindow.isVisible()) {
|
if (newWindow.isVisible()) {
|
||||||
// only open the dev tools if they aren't already open
|
// only open the dev tools if they aren't already open
|
||||||
if (isDev && !newWindow.webContents.isDevToolsOpened()) {
|
if (process.env.NODE_ENV === 'development' && !newWindow.webContents.isDevToolsOpened()) {
|
||||||
newWindow.webContents.openDevTools({ activate: false })
|
newWindow.webContents.openDevTools({ activate: false })
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -443,7 +442,7 @@ function runApp() {
|
||||||
newWindow.show()
|
newWindow.show()
|
||||||
newWindow.focus()
|
newWindow.focus()
|
||||||
|
|
||||||
if (isDev) {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
newWindow.webContents.openDevTools({ activate: false })
|
newWindow.webContents.openDevTools({ activate: false })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -479,7 +478,7 @@ function runApp() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.once('relaunchRequest', () => {
|
ipcMain.once('relaunchRequest', () => {
|
||||||
if (isDev) {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
app.exit(parseInt(process.env.FREETUBE_RELAUNCH_EXIT_CODE))
|
app.exit(parseInt(process.env.FREETUBE_RELAUNCH_EXIT_CODE))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,9 @@ import { createWebURL } from '../helpers/utils'
|
||||||
// List of locales approved for use
|
// List of locales approved for use
|
||||||
import activeLocales from '../../../static/locales/activeLocales.json'
|
import activeLocales from '../../../static/locales/activeLocales.json'
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV === 'development'
|
|
||||||
|
|
||||||
const messages = {}
|
const messages = {}
|
||||||
|
|
||||||
if (isDev && process.env.IS_ELECTRON) {
|
if (process.env.NODE_ENV === 'development' && process.env.IS_ELECTRON) {
|
||||||
const { load } = require('js-yaml')
|
const { load } = require('js-yaml')
|
||||||
|
|
||||||
// Take active locales and load respective YAML file
|
// Take active locales and load respective YAML file
|
||||||
|
@ -32,7 +30,7 @@ class CustomVueI18n extends VueI18n {
|
||||||
|
|
||||||
async loadLocale(locale) {
|
async loadLocale(locale) {
|
||||||
// we don't lazy load locales in development in electron
|
// we don't lazy load locales in development in electron
|
||||||
if (isDev && process.env.IS_ELECTRON) { return }
|
if (process.env.NODE_ENV === 'development' && process.env.IS_ELECTRON) { return }
|
||||||
// don't need to load it if it's already loaded
|
// don't need to load it if it's already loaded
|
||||||
if (this.availableLocales.includes(locale)) {
|
if (this.availableLocales.includes(locale)) {
|
||||||
return
|
return
|
||||||
|
@ -71,7 +69,7 @@ const i18n = new CustomVueI18n({
|
||||||
messages
|
messages
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!isDev || !process.env.IS_ELECTRON) {
|
if (process.env.NODE_ENV !== 'development' || !process.env.IS_ELECTRON) {
|
||||||
i18n.loadLocale('en-US')
|
i18n.loadLocale('en-US')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,9 @@ import { faMonero } from '@fortawesome/free-brands-svg-icons/faMonero'
|
||||||
import { faMastodon } from '@fortawesome/free-brands-svg-icons/faMastodon'
|
import { faMastodon } from '@fortawesome/free-brands-svg-icons/faMastodon'
|
||||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV === 'development'
|
Vue.config.devtools = process.env.NODE_ENV === 'development'
|
||||||
|
Vue.config.performance = process.env.NODE_ENV === 'development'
|
||||||
Vue.config.devtools = isDev
|
Vue.config.productionTip = process.env.NODE_ENV === 'development'
|
||||||
Vue.config.performance = isDev
|
|
||||||
Vue.config.productionTip = isDev
|
|
||||||
|
|
||||||
library.add(
|
library.add(
|
||||||
// solid icons
|
// solid icons
|
||||||
|
|
|
@ -20,8 +20,6 @@ import {
|
||||||
showToast
|
showToast
|
||||||
} from '../../helpers/utils'
|
} from '../../helpers/utils'
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV === 'development'
|
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
name: 'Watch',
|
name: 'Watch',
|
||||||
components: {
|
components: {
|
||||||
|
@ -1199,7 +1197,7 @@ export default Vue.extend({
|
||||||
|
|
||||||
if (this.removeVideoMetaFiles) {
|
if (this.removeVideoMetaFiles) {
|
||||||
const userData = await this.getUserDataPath()
|
const userData = await this.getUserDataPath()
|
||||||
if (isDev) {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
const dashFileLocation = `static/dashFiles/${videoId}.xml`
|
const dashFileLocation = `static/dashFiles/${videoId}.xml`
|
||||||
const vttFileLocation = `static/storyboards/${videoId}.vtt`
|
const vttFileLocation = `static/storyboards/${videoId}.vtt`
|
||||||
// only delete the file it actually exists
|
// only delete the file it actually exists
|
||||||
|
@ -1246,7 +1244,7 @@ export default Vue.extend({
|
||||||
const userData = await this.getUserDataPath()
|
const userData = await this.getUserDataPath()
|
||||||
let fileLocation
|
let fileLocation
|
||||||
let uriSchema
|
let uriSchema
|
||||||
if (isDev) {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
fileLocation = `static/dashFiles/${this.videoId}.xml`
|
fileLocation = `static/dashFiles/${this.videoId}.xml`
|
||||||
uriSchema = `dashFiles/${this.videoId}.xml`
|
uriSchema = `dashFiles/${this.videoId}.xml`
|
||||||
// if the location does not exist, writeFileSync will not create the directory, so we have to do that manually
|
// if the location does not exist, writeFileSync will not create the directory, so we have to do that manually
|
||||||
|
@ -1327,7 +1325,7 @@ export default Vue.extend({
|
||||||
|
|
||||||
// Dev mode doesn't have access to the file:// schema, so we access
|
// Dev mode doesn't have access to the file:// schema, so we access
|
||||||
// storyboards differently when run in dev
|
// storyboards differently when run in dev
|
||||||
if (isDev) {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
fileLocation = `static/storyboards/${this.videoId}.vtt`
|
fileLocation = `static/storyboards/${this.videoId}.vtt`
|
||||||
uriSchema = `storyboards/${this.videoId}.vtt`
|
uriSchema = `storyboards/${this.videoId}.vtt`
|
||||||
// if the location does not exist, writeFileSync will not create the directory, so we have to do that manually
|
// if the location does not exist, writeFileSync will not create the directory, so we have to do that manually
|
||||||
|
|
Loading…
Reference in New Issue