@@ -8,7 +8,7 @@ export function watchConfigFile(): PluginOption {
8
8
name : 'storyblok-field-plugin-watch-config-file' ,
9
9
handleHotUpdate ( { file, server } ) {
10
10
if ( file . endsWith ( 'field-plugin.config.json' ) ) {
11
- printServerUrls ( server )
11
+ printSandboxUrl ( server )
12
12
}
13
13
} ,
14
14
}
@@ -40,6 +40,7 @@ export function printDev(): PluginOption {
40
40
// Overrides the message that Vite prints out when the server is started. To reduce complexity, it does not include color
41
41
server . printUrls = ( ) => {
42
42
printServerUrls ( server )
43
+ printSandboxUrl ( server )
43
44
}
44
45
} ,
45
46
}
@@ -62,11 +63,18 @@ function printServerUrls(server: ViteDevServer) {
62
63
63
64
${ arrows . green } ${ bold ( 'Local' ) } : ${ localUrl }
64
65
${ arrows . green } ${ bold ( 'Network' ) } : ${ networkUrl }
65
-
66
- See the plugin in action on
67
-
68
- ${ arrows . green } ${ bold ( 'Sandbox' ) } : ${ generateSandboxUrl ( localUrl ) }
69
66
` )
70
67
}
71
68
69
+ function printSandboxUrl ( server : ViteDevServer ) {
70
+ if ( ! server . resolvedUrls ) {
71
+ return
72
+ }
73
+ const localUrl = server . resolvedUrls . local [ 0 ]
74
+
75
+ console . log ( ` See the plugin in action on
76
+
77
+ ${ arrows . green } ${ bold ( 'Sandbox' ) } : ${ generateSandboxUrl ( localUrl ) } ` )
78
+ }
79
+
72
80
export const plugins = [ printProd ( ) , printDev ( ) , watchConfigFile ( ) ]
0 commit comments