Replies: 1 comment
-
Hi @demyte ! For dev mode I usually have a server plugin that helps me with these specifics: export const serverPlugin = (): Plugin => ({
name: 'server-plugin',
apply: 'serve',
configureServer(server) {
server.middlewares.use('/functions.js', async (req, res, next) => {
const transformed = await server.transformRequest('./src/functions/functions.ts');
if (!transformed) return next(); // let Vite handle 404 or fallback
res.setHeader('Content-Type', 'application/javascript');
res.end(transformed.code);
});
}
}) There might an easier way, but I couldn't find in the docs or Vite's code. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am trying to add a secondary entry point to my Vite build (react) where there is a standard one through my
index.html
and then I have another one pointing to a specific file to build it out and its dependencies.The second one is at say:
./src/functions/functions.ts
and I would like it to be referenced at<baseUrl>/functions.js
.I have tried and failed over and over to get this to work using config in
build.rollupOptions.input
oroptimizeDeps.entries
and must just be missing something.For the config when using
optimizeDeps
, I have this in myvite.config.ts
:This gives me this
manifest.json
:For the config when using
build.rollupOptions.input
, I have this in myvite.config.ts
:This gives me this
manifest.json
which seems to now exclude the reference from myindex.html
to/src/main.tsx
:So then I tried this in my
vite.config.json
:This gives me this
manifest.json
, which looks like it should work, but when I go to<baseUrl>/functions.js
in Dev mode, it is not there:Appreciate any and all help.
Beta Was this translation helpful? Give feedback.
All reactions