I have a multi page app that I'm trying to build with Vite.js
(migrating from Webpack
). When building the Vite + React example code I see that it emits:
dist/index.html
dist/assets/<various assets>
However, when I try to make a multi page app as shown in the docs none of the HTMLs are emitted (but the rest of the content of /assets/
is there). Why is this?
// vite.config.js excerpt:
import { defineConfig } from 'vite'
import { dirname } from 'path';
import { fileURLToPath } from 'url';
export default defineConfig({
root: 'client',
build: {
outDir: 'dist',
rollupOptions: {
input: {
main: dirname(fileURLToPath(import.meta.url + 'index.html')),
login: dirname(fileURLToPath(import.meta.url + 'login.html')),
}
}
},
});
I have a multi page app that I'm trying to build with Vite.js
(migrating from Webpack
). When building the Vite + React example code I see that it emits:
dist/index.html
dist/assets/<various assets>
However, when I try to make a multi page app as shown in the docs none of the HTMLs are emitted (but the rest of the content of /assets/
is there). Why is this?
// vite.config.js excerpt:
import { defineConfig } from 'vite'
import { dirname } from 'path';
import { fileURLToPath } from 'url';
export default defineConfig({
root: 'client',
build: {
outDir: 'dist',
rollupOptions: {
input: {
main: dirname(fileURLToPath(import.meta.url + 'index.html')),
login: dirname(fileURLToPath(import.meta.url + 'login.html')),
}
}
},
});
dirname
which is removing the filename only directory names will be left out.
– Chandan
Commented
Aug 18, 2021 at 6:07
vite build
that says SyntaxError: Assigning to rvalue
.
– Michael Johansen
Commented
Aug 19, 2021 at 17:29
new URL(
./index.html, import.meta.url)
as specified in the vite doc.
– Chandan
Commented
Aug 20, 2021 at 3:30
main: new URL('./client/index.html', import.meta.url).pathname,
– Michael Johansen
Commented
Aug 21, 2021 at 20:18
Try using the URL
for file input as specified in vite doc
main: new URL('./client/index.html', import.meta.url).pathname