Cleanup: Define routerBasePath constant in nuxt.config.js

This commit is contained in:
mikiher 2024-10-12 11:46:44 +03:00
parent 69dd82d329
commit 99ffd3050c

View File

@ -1,19 +1,21 @@
const pkg = require('./package.json')
const routerBasePath = process.env.ROUTER_BASE_PATH || ''
module.exports = {
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
ssr: false,
target: 'static',
dev: process.env.NODE_ENV !== 'production',
env: {
serverUrl: process.env.NODE_ENV === 'production' ? process.env.ROUTER_BASE_PATH || '' : 'http://localhost:3333',
serverUrl: process.env.NODE_ENV === 'production' ? routerBasePath : 'http://localhost:3333',
chromecastReceiver: 'FD1F76C5'
},
telemetry: false,
publicRuntimeConfig: {
version: pkg.version,
routerBasePath: process.env.ROUTER_BASE_PATH || ''
routerBasePath
},
// Global page headers: https://go.nuxtjs.dev/config-head
@ -30,13 +32,13 @@ module.exports = {
],
script: [],
link: [
{ rel: 'icon', type: 'image/x-icon', href: (process.env.ROUTER_BASE_PATH || '') + '/favicon.ico' },
{ rel: 'apple-touch-icon', href: (process.env.ROUTER_BASE_PATH || '') + '/ios_icon.png' }
{ rel: 'icon', type: 'image/x-icon', href: routerBasePath + '/favicon.ico' },
{ rel: 'apple-touch-icon', href: routerBasePath + '/ios_icon.png' }
]
},
router: {
base: process.env.ROUTER_BASE_PATH || ''
base: routerBasePath
},
// Global CSS: https://go.nuxtjs.dev/config-css
@ -72,7 +74,7 @@ module.exports = {
],
proxy: {
[`${process.env.ROUTER_BASE_PATH || ''}/api/`]: { target: process.env.NODE_ENV !== 'production' ? 'http://localhost:3333' : '/' }
[`${routerBasePath}/api/`]: { target: process.env.NODE_ENV !== 'production' ? 'http://localhost:3333' : '/' }
},
io: {
@ -87,7 +89,7 @@ module.exports = {
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
baseURL: process.env.ROUTER_BASE_PATH || ''
baseURL: routerBasePath
},
// nuxt/pwa https://pwa.nuxtjs.org
@ -107,11 +109,11 @@ module.exports = {
background_color: '#232323',
icons: [
{
src: (process.env.ROUTER_BASE_PATH || '') + '/icon.svg',
src: routerBasePath + '/icon.svg',
sizes: 'any'
},
{
src: (process.env.ROUTER_BASE_PATH || '') + '/icon192.png',
src: routerBasePath + '/icon192.png',
type: 'image/png',
sizes: 'any'
}