Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outputting a single file per entrypoint doesn't work #64

Closed
aszenz opened this issue Aug 28, 2023 · 2 comments
Closed

Outputting a single file per entrypoint doesn't work #64

aszenz opened this issue Aug 28, 2023 · 2 comments

Comments

@aszenz
Copy link

aszenz commented Aug 28, 2023

I would like to have one js file per entrypoint (input) in my final build, as per https://symfony-vite.pentatrion.com/guide/tips.html#one-file-by-entry-point I should set manualChunks to undefined but that didn't work for me on vite 4.0 and symfony 6.3, I see many js files being imported as before.

Vite config:

import { defineConfig } from 'vite';
import symfonyPlugin from 'vite-plugin-symfony';
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
import checker from 'vite-plugin-checker';
import elmPlugin from 'vite-plugin-elm';

export default defineConfig({
    plugins: [
        checker({
            // e.g. use TypeScript check
            typescript: true,
            // eslint: true
        }),
        elmPlugin(),
        react(),
        symfonyPlugin(),
        tsconfigPaths(),
    ],
    publicDir: false,
    base: '/build',
    build: {
        outDir: '../public/build',
        assetsDir: './',
        emptyOutDir: true,
        sourcemap: true,
        rollupOptions: {
            input: {
             // multiple inputs here
              app1: './App1/index.ts',
              app2: './App2/index.ts'
            },
            output: {
              manualChunks: undefined,
            },
        },
    },
});

I would like to just see everything bundled up in app1.js, app2.js

Related issues:
vitejs/vite#12203

Maybe it relates to an upstream issue in rollup which vite uses internally for bundling:
rollup/rollup#2756

@lhapaipai
Copy link
Owner

I understand, it sometimes happens that rollup makes groupings that we don't like. unfortunately vite-plugin-symfony won't be able to do anything about it. I advise you to create your own manualChunks function who will solve your constraints.
Good day

@lhapaipai lhapaipai closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2023
@aszenz
Copy link
Author

aszenz commented Sep 2, 2023

I understand, it sometimes happens that rollup makes groupings that we don't like. unfortunately vite-plugin-symfony won't be able to do anything about it. I advise you to create your own manualChunks function who will solve your constraints.
Good day

Updated the docs in https://github.com/lhapaipai/symfony-vite-docs/pull/1 to reflect the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants