Fix some development code not getting optimised out (#2605)
This commit is contained in:
parent
8e72e7fe5f
commit
fa8d423bc6
|
@ -18,15 +18,16 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
<% if (process.env.NODE_ENV !== 'development') { %>
|
||||||
<!-- Set `__static` path to static files in production -->
|
<!-- Set `__static` path to static files in production -->
|
||||||
<script>
|
<script>
|
||||||
try {
|
try {
|
||||||
if ('<%= process.env.NODE_ENV %>' !== 'development')
|
|
||||||
window.__static = require('path')
|
window.__static = require('path')
|
||||||
.join(__dirname, '/static')
|
.join(__dirname, '/static')
|
||||||
.replace(/\\/g, '\\\\')
|
.replace(/\\/g, '\\\\')
|
||||||
} catch {}
|
} catch {}
|
||||||
</script>
|
</script>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// This is the service worker with the Advanced caching
|
// This is the service worker with the Advanced caching
|
||||||
|
|
|
@ -50,9 +50,6 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isDev: function () {
|
|
||||||
return process.env.NODE_ENV === 'development'
|
|
||||||
},
|
|
||||||
isOpen: function () {
|
isOpen: function () {
|
||||||
return this.$store.getters.getIsSideNavOpen
|
return this.$store.getters.getIsSideNavOpen
|
||||||
},
|
},
|
||||||
|
@ -148,7 +145,7 @@ export default Vue.extend({
|
||||||
this.grabUserSettings().then(async () => {
|
this.grabUserSettings().then(async () => {
|
||||||
this.checkThemeSettings()
|
this.checkThemeSettings()
|
||||||
|
|
||||||
await this.fetchInvidiousInstances({ isDev: this.isDev })
|
await this.fetchInvidiousInstances()
|
||||||
if (this.defaultInvidiousInstance === '') {
|
if (this.defaultInvidiousInstance === '') {
|
||||||
await this.setRandomCurrentInvidiousInstance()
|
await this.setRandomCurrentInvidiousInstance()
|
||||||
}
|
}
|
||||||
|
@ -257,7 +254,6 @@ export default Vue.extend({
|
||||||
|
|
||||||
checkExternalPlayer: async function () {
|
checkExternalPlayer: async function () {
|
||||||
const payload = {
|
const payload = {
|
||||||
isDev: this.isDev,
|
|
||||||
externalPlayer: this.externalPlayer
|
externalPlayer: this.externalPlayer
|
||||||
}
|
}
|
||||||
this.getExternalPlayerCmdArgumentsData(payload)
|
this.getExternalPlayerCmdArgumentsData(payload)
|
||||||
|
|
|
@ -21,10 +21,6 @@ export default Vue.extend({
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isDev: function () {
|
|
||||||
return process.env.NODE_ENV === 'development'
|
|
||||||
},
|
|
||||||
|
|
||||||
externalPlayerNames: function () {
|
externalPlayerNames: function () {
|
||||||
const fallbackNames = this.$store.getters.getExternalPlayerNames
|
const fallbackNames = this.$store.getters.getExternalPlayerNames
|
||||||
const nameTranslationKeys = this.$store.getters.getExternalPlayerNameTranslationKeys
|
const nameTranslationKeys = this.$store.getters.getExternalPlayerNameTranslationKeys
|
||||||
|
|
|
@ -61,9 +61,6 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isDev: function () {
|
|
||||||
return process.env.NODE_ENV === 'development'
|
|
||||||
},
|
|
||||||
currentInvidiousInstance: function () {
|
currentInvidiousInstance: function () {
|
||||||
return this.$store.getters.getCurrentInvidiousInstance
|
return this.$store.getters.getCurrentInvidiousInstance
|
||||||
},
|
},
|
||||||
|
|
|
@ -42,10 +42,6 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isDev: function () {
|
|
||||||
return process.env.NODE_ENV === 'development'
|
|
||||||
},
|
|
||||||
|
|
||||||
backendPreference: function () {
|
backendPreference: function () {
|
||||||
return this.$store.getters.getBackendPreference
|
return this.$store.getters.getBackendPreference
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,7 +21,7 @@ const getters = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
async fetchInvidiousInstances({ commit }, payload) {
|
async fetchInvidiousInstances({ commit }) {
|
||||||
const requestUrl = 'https://api.invidious.io/instances.json'
|
const requestUrl = 'https://api.invidious.io/instances.json'
|
||||||
|
|
||||||
let instances = []
|
let instances = []
|
||||||
|
@ -43,7 +43,7 @@ const actions = {
|
||||||
// And fallback to hardcoded entry(s) if static file absent
|
// And fallback to hardcoded entry(s) if static file absent
|
||||||
const fileName = 'invidious-instances.json'
|
const fileName = 'invidious-instances.json'
|
||||||
/* eslint-disable-next-line */
|
/* eslint-disable-next-line */
|
||||||
const fileLocation = payload.isDev ? './static/' : `${__dirname}/static/`
|
const fileLocation = process.env.NODE_ENV === 'development' ? './static/' : `${__dirname}/static/`
|
||||||
if (fs.existsSync(`${fileLocation}${fileName}`)) {
|
if (fs.existsSync(`${fileLocation}${fileName}`)) {
|
||||||
console.warn('reading static file for invidious instances')
|
console.warn('reading static file for invidious instances')
|
||||||
const fileData = fs.readFileSync(`${fileLocation}${fileName}`)
|
const fileData = fs.readFileSync(`${fileLocation}${fileName}`)
|
||||||
|
|
|
@ -323,7 +323,6 @@ const stateWithSideEffects = {
|
||||||
|
|
||||||
i18n.locale = targetLocale
|
i18n.locale = targetLocale
|
||||||
dispatch('getRegionData', {
|
dispatch('getRegionData', {
|
||||||
isDev: process.env.NODE_ENV === 'development',
|
|
||||||
locale: targetLocale
|
locale: targetLocale
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -547,7 +547,7 @@ const actions = {
|
||||||
getRegionData ({ commit }, payload) {
|
getRegionData ({ commit }, payload) {
|
||||||
let fileData
|
let fileData
|
||||||
/* eslint-disable-next-line */
|
/* eslint-disable-next-line */
|
||||||
const fileLocation = payload.isDev ? './static/geolocations/' : `${__dirname}/static/geolocations/`
|
const fileLocation = process.env.NODE_ENV === 'development' ? './static/geolocations/' : `${__dirname}/static/geolocations/`
|
||||||
if (fs.existsSync(`${fileLocation}${payload.locale}`)) {
|
if (fs.existsSync(`${fileLocation}${payload.locale}`)) {
|
||||||
fileData = fs.readFileSync(`${fileLocation}${payload.locale}/countries.json`)
|
fileData = fs.readFileSync(`${fileLocation}${payload.locale}/countries.json`)
|
||||||
} else {
|
} else {
|
||||||
|
@ -1028,7 +1028,7 @@ const actions = {
|
||||||
const fileName = 'external-player-map.json'
|
const fileName = 'external-player-map.json'
|
||||||
let fileData
|
let fileData
|
||||||
/* eslint-disable-next-line */
|
/* eslint-disable-next-line */
|
||||||
const fileLocation = payload.isDev ? './static/' : `${__dirname}/static/`
|
const fileLocation = process.env.NODE_ENV === 'development' ? './static/' : `${__dirname}/static/`
|
||||||
|
|
||||||
if (fs.existsSync(`${fileLocation}${fileName}`)) {
|
if (fs.existsSync(`${fileLocation}${fileName}`)) {
|
||||||
fileData = fs.readFileSync(`${fileLocation}${fileName}`)
|
fileData = fs.readFileSync(`${fileLocation}${fileName}`)
|
||||||
|
|
|
@ -16,6 +16,8 @@ import WatchVideoRecommendations from '../../components/watch-video-recommendati
|
||||||
import FtAgeRestricted from '../../components/ft-age-restricted/ft-age-restricted.vue'
|
import FtAgeRestricted from '../../components/ft-age-restricted/ft-age-restricted.vue'
|
||||||
import i18n from '../../i18n/index'
|
import i18n from '../../i18n/index'
|
||||||
|
|
||||||
|
const isDev = process.env.NODE_ENV === 'development'
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
name: 'Watch',
|
name: 'Watch',
|
||||||
components: {
|
components: {
|
||||||
|
@ -86,9 +88,6 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isDev: function () {
|
|
||||||
return process.env.NODE_ENV === 'development'
|
|
||||||
},
|
|
||||||
historyCache: function () {
|
historyCache: function () {
|
||||||
return this.$store.getters.getHistoryCache
|
return this.$store.getters.getHistoryCache
|
||||||
},
|
},
|
||||||
|
@ -1127,7 +1126,7 @@ export default Vue.extend({
|
||||||
|
|
||||||
if (this.removeVideoMetaFiles) {
|
if (this.removeVideoMetaFiles) {
|
||||||
const userData = await this.getUserDataPath()
|
const userData = await this.getUserDataPath()
|
||||||
if (this.isDev) {
|
if (isDev) {
|
||||||
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
|
||||||
|
@ -1174,7 +1173,7 @@ export default Vue.extend({
|
||||||
const userData = await this.getUserDataPath()
|
const userData = await this.getUserDataPath()
|
||||||
let fileLocation
|
let fileLocation
|
||||||
let uriSchema
|
let uriSchema
|
||||||
if (this.isDev) {
|
if (isDev) {
|
||||||
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
|
||||||
|
@ -1255,7 +1254,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 (this.isDev) {
|
if (isDev) {
|
||||||
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