File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## Unreleased
4+
5+ - Add support for Vite base path
6+
37## 4.0.0
48
59- Align with Vite 7: ESM only, node 20.19+
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ style.innerHTML = `[data-click-to-component-target] {
3737document . head . appendChild ( style ) ;
3838
3939const root = "__ROOT__" ;
40+ const base = "__BASE__" ;
4041let currentTarget : HTMLElement | undefined ;
4142let hasMenu = false ;
4243const menuElement = document . createElement ( "div" ) ;
@@ -123,7 +124,9 @@ window.addEventListener("contextmenu", (event) => {
123124 spanR . textContent = layer . path . replace ( `${ root } /` , "" ) ;
124125 item . appendChild ( spanR ) ;
125126 item . addEventListener ( "click" , ( ) => {
126- void fetch ( `/__open-in-editor?file=${ encodeURIComponent ( layer . path ) } ` ) ;
127+ void fetch (
128+ `${ base } __open-in-editor?file=${ encodeURIComponent ( layer . path ) } ` ,
129+ ) ;
127130 cleanUp ( ) ;
128131 } ) ;
129132 menuElement . appendChild ( item ) ;
Original file line number Diff line number Diff line change @@ -3,21 +3,22 @@ import { join } from "node:path";
33import type { PluginOption } from "vite" ;
44
55let root = "" ;
6+ let base = "" ;
67
78export const reactClickToComponent = ( ) : PluginOption => ( {
89 name : "react-click-to-component" ,
910 apply : "serve" ,
1011 configResolved ( config ) {
1112 root = config . root ;
13+ base = config . base ;
1214 } ,
1315 transformIndexHtml : ( ) => [
1416 {
1517 tag : "script" ,
1618 attrs : { type : "module" } ,
17- children : readFileSync (
18- join ( import . meta. dirname , "client.js" ) ,
19- "utf-8" ,
20- ) . replace ( "__ROOT__" , root ) ,
19+ children : readFileSync ( join ( import . meta. dirname , "client.js" ) , "utf-8" )
20+ . replace ( "__ROOT__" , root )
21+ . replace ( "__BASE__" , base ) ,
2122 } ,
2223 ] ,
2324 transform ( code , id ) {
You can’t perform that action at this time.
0 commit comments