File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
packages/field-plugin/helpers/vite/src Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -2,12 +2,15 @@ import type { PluginOption, ViteDevServer } from 'vite'
2
2
import { generateSandboxUrl } from './sandbox'
3
3
import { bold , green } from './utils/text'
4
4
import { arrows } from './utils/arrows'
5
+ import { MANIFEST_FILE_NAME } from '@storyblok/manifest-helper'
6
+ import path from 'path'
5
7
6
8
export function watchConfigFile ( ) : PluginOption {
7
9
return {
8
10
name : 'storyblok-field-plugin-watch-config-file' ,
9
11
handleHotUpdate ( { file, server } ) {
10
- if ( file . endsWith ( 'field-plugin.config.json' ) ) {
12
+ // NOTE: This condition checks if the file is on the same directory level as where the command has been executed and checks the file name
13
+ if ( isFileInSameLevel ( file ) && getFileName ( file ) === MANIFEST_FILE_NAME ) {
11
14
printSandboxUrl ( server )
12
15
}
13
16
} ,
@@ -78,3 +81,14 @@ function printSandboxUrl(server: ViteDevServer) {
78
81
}
79
82
80
83
export const plugins = [ printProd ( ) , printDev ( ) , watchConfigFile ( ) ]
84
+
85
+ function getFileName ( filePath : string ) {
86
+ return path . basename ( filePath )
87
+ }
88
+
89
+ function isFileInSameLevel ( fileName : string ) : boolean {
90
+ const currentDir = process . cwd ( )
91
+ const filePath = path . resolve ( currentDir , fileName )
92
+ const fileDir = path . dirname ( filePath )
93
+ return currentDir === fileDir
94
+ }
You can’t perform that action at this time.
0 commit comments