'Vite: placing bundles in subfolders on build?

Currently my projects structure is:

my-app/
├─ node_modules/
├─ dist/
│  ├─ assets/
│  │  ├─ main.js
│  │  ├─ nested.js
│  │  ├─ styles.css
│  │  ├─ nestedstyles.css
│  ├─ nested/
│  │  ├─ index.html
│  ├─ index.html
├─ nested/
│  ├─index.html
│  ├─nested.js
│  ├─nestedstyles.scss
├─ index.html
├─ main.js
├─ style.scss
├─ package.json

I'm looking to create:

my-app/
├─ node_modules/
├─ dist/
│  ├─ assets/
│  │  ├─ main.js
│  │  ├─ styles.css
│  ├─ nested/
│  │  ├─ assets/
│  │  │  ├─ nested.js
│  │  │  ├─ nestedstyles.css
│  │  ├─ index.html
│  ├─ index.html
├─ nested/
│  ├─index.html
│  ├─nested.js
│  ├─nestedstyles.scss
├─ index.html
├─ main.js
├─ style.scss
├─ package.json

This is what I currently have for my rollupOptions:

    module.exports = defineConfig({
    build: {
        rollupOptions: {
            input: {
                main: resolve(__dirname, 'index.html'),
                nested: resolve(__dirname, 'nested/index.html')
            },
        }
    }
})

So far anything I have tried hasn't been able to keep the nested bundles in the nested folder. How would I go about accomplishing this?

Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source