Skip to content

Commit

Permalink
fix(editor): fix BASE_PATH for Vite dev mode (#4342)
Browse files Browse the repository at this point in the history
* 🐛 Fix `BASE_PATH` for Vite dev mode

* don't use the string `/{{BASE_PATH}}/` as it gets replaces in build

* fix the static urls on windows

* ffs node 14

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
  • Loading branch information
ivov and netroy authored Oct 14, 2022
1 parent 32fb298 commit 24288a5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ class App {
const srcFile = await readFile(filePath, 'utf8');
let payload = srcFile
.replace(basePathRegEx, n8nPath)
.replace(/\/static\//g, pathJoin(n8nPath, 'static/'));
.replace(/\/static\//g, n8nPath + 'static/');
if (filePath.endsWith('index.html')) {
payload = payload.replace(closingTitleTag, closingTitleTag + scriptsString);
}
Expand Down
3 changes: 1 addition & 2 deletions packages/editor-ui/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ function getTemplatesRedirect(store: Store<IRootState>) {

const router = new Router({
mode: 'history',
// @ts-ignore
base: window.BASE_PATH ?? '/',
base: import.meta.env.DEV ? '/' : window.BASE_PATH ?? '/',
scrollBehavior(to, from, savedPosition) {
// saved position == null means the page is NOT visited from history (back button)
if (savedPosition === null && to.name === VIEWS.TEMPLATES && to.meta) {
Expand Down
4 changes: 4 additions & 0 deletions packages/editor-ui/src/shims.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ declare module 'markdown-it-emoji';
declare module 'markdown-it-task-lists';

declare global {
interface Window {
BASE_PATH: string;
}

namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
Expand Down

0 comments on commit 24288a5

Please sign in to comment.