Skip to content

Commit

Permalink
Set Base URL for production Build
Browse files Browse the repository at this point in the history
  • Loading branch information
Morl99 committed Oct 2, 2024
1 parent a743c2b commit f5c4944
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/control-center/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly BASE_URL: string
}

interface ImportMeta {
readonly env: ImportMetaEnv
}
2 changes: 1 addition & 1 deletion src/control-center/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
"build-only": "vite build",
"build-only": "vite build --base=/PopupSim/",
"coverage": "npm run test:unit -- --coverage",
"preview": "vite preview --port 4173",
"test": "npm run test:unit",
Expand Down
2 changes: 1 addition & 1 deletion src/control-center/src/views/ImprintView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { onMounted, ref } from 'vue'
let licensesTxt = ref<string>()
onMounted(async () => {
fetch(`/dependencies.txt`)
fetch(`${import.meta.env.BASE_URL}/dependencies.txt`)
.then((response) => response.text())
.then((res) => {
licensesTxt.value = res
Expand Down
4 changes: 2 additions & 2 deletions src/control-center/src/views/VisualizerView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function render() {
//draw background
var baseImage = new Image()
baseImage.src = 'rail_icons/edited.png'
baseImage.src = `${import.meta.env.BASE_URL}rail_icons/edited.png`
baseImage.onload = function () {
ctx.drawImage(baseImage, 0, 0)
}
Expand Down Expand Up @@ -162,7 +162,7 @@ function drawColoredRect(ctx, x, y, color) {
function drawImage(ctx, name, x, y) {
const image = new Image()
image.src = `/rail_icons/${name}`
image.src = `${import.meta.env.BASE_URL}rail_icons/${name}`
image.onload = function () {
ctx.drawImage(this, x, y)
}
Expand Down
1 change: 1 addition & 0 deletions src/control-center/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"strict": false,
"types": ["vite/client"],
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"baseUrl": ".",
Expand Down

0 comments on commit f5c4944

Please sign in to comment.