Piny 'Click to select' not working: Piny plugin order with tanstack in vite?

Hi team, it’s a wonderful project but recently i have been having trouble getting Piny to work with a tanstack app created with vite. the specific issue is that i cannot get ‘Click to select’ to work.
I suspect the plugin order in vite.config.ts maybe the issue.

here is the current (not working) vite config.

is there a workaround i can try?

thank u.

import { defineConfig } from 'vite'
import { devtools } from '@tanstack/devtools-vite'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import viteReact from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import PinyVite from '@pinegrow/piny-vite'




const config = defineConfig({

resolve: { tsconfigPaths: true },

plugins: [ 

devtools(),

tailwindcss(), 

tanstackStart(), 

viteReact(),

PinyVite()  

  ]

})

export default config

I just tried tanstack with piny, and it works for me - GitHub - TechAkayy/tanstack-vite · GitHub. Can you give this repo a shot.

thanks for the followup. your repo is great and works for me.

the default vite command to install tanstack router insists on installing tanstack Start (the template). this interferes with injecting piny into the page.

i found out you need to add {import.meta.env.DEV && } in __root.tsx as below.

1 Like

I didn’t quite catch the issue with your setup.

If you check `node_modules/@pinegrow/piny-vite/dist/index.js`, the runtime path is automatically injected (screeenshot below). Does you setup does something that interferes with this? Your feedback is welcome, so that we can improve our setup. Thanks!

hi @TechAkayy ,

apologies for the delay in replying.
i setup a ‘tanstack router’ app and selected all the other tanstack modules: DB, Form, Table, Store, Query.

i’m using yarn, so i added ‘Click to Select’ with: ‘yarn add @pinegrow/piny-vite --dev’

after adding Piny() to the vite config and running the app, Piny doesn’t inject.

i tried various plugin orders but none work.

Thanks @vips. That was very useful. Our piny vite plugin uses `transformIndexHtml` to inject piny into the shell index.html which is present in vanilla tanstack app (my git repo), while in the full tanstack app you shared, there is no shell, and is generated dynamically. We will patch it up to cover this scenario if possible. cc: @matjaz

Meanwhile, your hack adding it to __root.tsx was a smart one. Thanks for sharing.