From 543dd9e3851c197e90ba97a976cf145ff28bb0e1 Mon Sep 17 00:00:00 2001 From: Razvan Stoenescu Date: Mon, 31 Jul 2023 16:41:41 +0300 Subject: [PATCH] feat(app-webpack): workaround vue/devtools issue when used with webpack --- app-webpack/lib/webpack/plugin.html-addons.js | 22 +++++++++++++------ app-webpack/templates/entry/app.js | 8 ------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app-webpack/lib/webpack/plugin.html-addons.js b/app-webpack/lib/webpack/plugin.html-addons.js index 922c6a533df..a8b12f3caa8 100644 --- a/app-webpack/lib/webpack/plugin.html-addons.js +++ b/app-webpack/lib/webpack/plugin.html-addons.js @@ -8,13 +8,13 @@ function makeTag (tagName, attributes, closeTag = false) { } } -// function makeScriptTag (innerHTML) { -// return { -// tagName: 'script', -// closeTag: true, -// innerHTML -// } -// } +function makeScriptTag (innerHTML) { + return { + tagName: 'script', + closeTag: true, + innerHTML + } +} function fillBaseTag (html, base) { return html.replace( @@ -39,6 +39,14 @@ module.exports.HtmlAddonsPlugin = class HtmlAddonsPlugin { data.html = fillBaseTag(data.html, this.cfg.build.appBase) } + if (this.cfg.metaConf.vueDevtools !== false) { + const { host, port } = this.cfg.metaConf.vueDevtools + data.headTags.push( + makeScriptTag(`window.__VUE_DEVTOOLS_HOST__ = '${ host }';window.__VUE_DEVTOOLS_PORT__ = '${ port }';`), + makeTag('script', { src: `http://${ host }:${ port }` }, true) + ) + } + if (this.cfg.ctx.mode.cordova) { data.bodyTags.unshift( makeTag('script', { src: 'cordova.js' }, true) diff --git a/app-webpack/templates/entry/app.js b/app-webpack/templates/entry/app.js index 97ca51e461d..2a9f712c55a 100644 --- a/app-webpack/templates/entry/app.js +++ b/app-webpack/templates/entry/app.js @@ -26,10 +26,6 @@ <% } %> <% } %> -<% if (metaConf.vueDevtools !== false) { %> -import vueDevtools from '@vue/devtools' -<% } %> - import { Quasar } from 'quasar' import { markRaw } from 'vue' import <%= metaConf.needsAppMountHook === true ? 'AppComponent' : 'RootComponent' %> from 'app/<%= sourceFiles.rootComponent %>' @@ -47,10 +43,6 @@ const RootComponent = defineComponent({ SplashScreen.hide() <% } %> - <% if (metaConf.vueDevtools !== false) { %> - vueDevtools.connect('<%= metaConf.vueDevtools.host %>', <%= metaConf.vueDevtools.port %>) - <% } %> - <% if (ctx.mode.ssr && ssr.manualPostHydrationTrigger !== true) { %> const { proxy: { $q } } = getCurrentInstance() $q.onSSRHydrated !== void 0 && $q.onSSRHydrated()