Skip to content

Commit 51fb89b

Browse files
authored
fix: remove completely devtools in hosting providers (#220)
* fix: remove completely devtools in hosting providers * changeset * add logs * log * fix for bundling * fix for bundling * fix
1 parent a5448af commit 51fb89b

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

.changeset/nine-ravens-push.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/devtools-vite': patch
3+
---
4+
5+
fix issue where hosting providers would include devtools in production

packages/devtools-vite/src/plugin.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,18 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array<Plugin> => {
178178
},
179179
{
180180
name: '@tanstack/devtools:remove-devtools-on-build',
181-
apply(_, { command }) {
182-
return command === 'build' && removeDevtoolsOnBuild
181+
apply(config, { command }) {
182+
// Check both command and mode to support various hosting providers
183+
// Some providers (Cloudflare, Netlify, Heroku) might not use 'build' command
184+
// but will always set mode to 'production' for production builds
185+
return (
186+
(command !== 'serve' || config.mode === 'production') &&
187+
removeDevtoolsOnBuild
188+
)
183189
},
184190
enforce: 'pre',
185191
transform(code, id) {
186-
if (
187-
id.includes('node_modules') ||
188-
id.includes('?raw') ||
189-
id.includes('dist') ||
190-
id.includes('build')
191-
)
192-
return
192+
if (id.includes('node_modules') || id.includes('?raw')) return
193193
const transform = removeDevtools(code, id)
194194
if (!transform) return
195195
if (logging) {

0 commit comments

Comments
 (0)