Skip to content

Commit 7cf21f6

Browse files
committed
allow the users to disable source injection
1 parent 91651c0 commit 7cf21f6

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎docs/vite-plugin.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ const open = (file: string, line: number) => {
9696
}
9797
```
9898

99+
- `injectSource` - Configuration for source injection. Defaults to enabled.
100+
101+
```ts
102+
{
103+
injectSource: {
104+
enabled: true
105+
}
106+
}
107+
```
108+
99109
## Features
100110

101111
### Go to source

‎packages/devtools-vite/src/plugin.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ export type TanStackDevtoolsViteConfig = {
2828
* @default true
2929
*/
3030
enabled: boolean
31+
},
32+
/**
33+
* Configuration for source injection.
34+
*/
35+
injectSource: {
36+
/**
37+
* Whether to enable source injection via data-tsd-source.
38+
* @default true
39+
*/
40+
enabled: boolean
3141
}
3242
}
3343

@@ -38,14 +48,15 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array<Plugin> => {
3848
let port = 5173
3949
const appDir = args?.appDir || './src'
4050
const enhancedLogsConfig = args?.enhancedLogs ?? { enabled: true }
51+
const injectSourceConfig = args?.injectSource ?? { enabled: true }
4152
const bus = new ServerEventBus(args?.eventBusConfig)
4253

4354
return [
4455
{
4556
enforce: 'pre',
4657
name: '@tanstack/devtools:inject-source',
4758
apply(config) {
48-
return config.mode === 'development'
59+
return config.mode === 'development' && injectSourceConfig.enabled
4960
},
5061
transform(code, id) {
5162
if (

0 commit comments

Comments
 (0)