@@ -16,7 +16,7 @@ import "dotenv/config"
1616
1717// @ts -expect-error commonjs module
1818import { defineViteConfig as define } from "./define.config.mjs"
19- import { resolve } from "node:path"
19+ import { dirname , relative , resolve } from "node:path"
2020
2121const IS_DEV = process . env . NODE_ENV === "development"
2222const PORT = Number ( process . env . PORT ) || 3303
@@ -28,9 +28,11 @@ const getImmediateDirectories = (path: string) =>
2828 . map ( ( entry ) => entry . name )
2929
3030export default defineConfig ( {
31- base : IS_DEV ? "/" : "" ,
31+ base : IS_DEV ? `http://localhost: ${ PORT } /` : "" ,
3232
3333 build : {
34+ watch : IS_DEV ? { } : undefined ,
35+ sourcemap : IS_DEV ? "inline" : false ,
3436 rollupOptions : {
3537 input : {
3638 setup : resolve ( __dirname , "src/ui/setup/index.html" ) ,
@@ -105,7 +107,9 @@ export default defineConfig({
105107 "@vueuse/core" ,
106108 { "vue-router/auto" : [ "definePage" ] } ,
107109 { "vue-i18n" : [ "useI18n" , "t" ] } ,
108- { "webextension-polyfill" : [ [ "*" , "browser" ] ] } ,
110+ {
111+ "webextension-polyfill" : [ [ "=" , "browser" ] ] ,
112+ } ,
109113 { notivue : [ "Notivue" , "Notification" , [ "push" , "pushNotification" ] ] } ,
110114 ] ,
111115 dts : "src/types/auto-imports.d.ts" ,
@@ -132,17 +136,18 @@ export default defineConfig({
132136 scale : 1.5 ,
133137 } ) ,
134138
135- // {
136- // name: "assets-rewrite",
137- // enforce: "post",
138- // // apply: "build",
139- // transformIndexHtml(html, { path }) {
140- // const assetsPath = path
141- // .replace(/\/[^/]+$/, "/assets")
142- // .replace(/\\/g, "/")
143- // return html.replace(/"\/assets\//g, `"${assetsPath}/`)
144- // },
145- // },
139+ // rewrite assets to use relative path
140+ {
141+ name : "assets-rewrite" ,
142+ enforce : "post" ,
143+ apply : "build" ,
144+ transformIndexHtml ( html , { path } ) {
145+ return html . replace (
146+ / " \/ a s s e t s \/ / g,
147+ `"${ relative ( dirname ( path ) , "/assets" ) } /` ,
148+ )
149+ } ,
150+ } ,
146151
147152 createHtmlPlugin ( { inject : { data : define } } ) ,
148153 ] ,
@@ -155,8 +160,12 @@ export default defineConfig({
155160 "@assets" : fileURLToPath ( new URL ( "src/assets" , import . meta. url ) ) ,
156161 } ,
157162 } ,
158-
159163 server : {
164+ port : PORT ,
165+ hmr : {
166+ host : "localhost" ,
167+ } ,
168+ origin : `http://localhost:${ PORT } ` ,
160169 cors : {
161170 origin : [
162171 // ⚠️ SECURITY RISK: Allows any chrome-extension to access the vite server ⚠️
0 commit comments