don't include log viewer in production build

This commit is contained in:
Bruno Windels 2022-05-10 20:08:58 +02:00
parent f6ea7803f2
commit e2621015e1
2 changed files with 8 additions and 3 deletions

View file

@ -142,9 +142,12 @@ export class SettingsView extends TemplateView {
}
}
async function openLogs(vm) {
const logviewerUrl = (await import("@matrixdotorg/structured-logviewer/index.html?url")).default;
const win = window.open(logviewerUrl);
// Use vite-specific url so this asset doesn't get picked up by vite and included in the production build,
// as opening the logs is only available during dev time, and @matrixdotorg/structured-logviewer is a dev dependency
// This url is what import "@matrixdotorg/structured-logviewer/index.html?url" resolves to with vite.
const win = window.open(`/@fs/${DEFINE_PROJECT_DIR}/node_modules/@matrixdotorg/structured-logviewer/index.html`);
await new Promise((resolve, reject) => {
let shouldSendPings = true;
const cleanup = () => {

View file

@ -37,6 +37,8 @@ export default defineConfig(({mode}) => {
"sw": definePlaceholders
}),
],
define: definePlaceholders,
define: Object.assign({
DEFINE_PROJECT_DIR: JSON.stringify(__dirname)
}, definePlaceholders),
});
});