javascripttypescriptviterollupjs

Output or log the vite rollup configuration?


When we create a vite project running npm run build will create the rollup javascript bundle.

However the command npm init vite@latest that we used to scaffold out the project does not create a rollup.config.js file.

Is there a way to output the default rollup configuration, so we can see what the settings used to create the bundle?


Solution

  • One of the Vite Maintainers said no, but we can get some options via a plugin. The plugin implementation is below and here's a Stackblitz demo.

    export default {
      plugins: [
        {
          name: 'log',
          options(options) {
            console.log('options', options);
          },
          outputOptions(outputOptions) {
            console.log('outputOptions', outputOptions);
          },
        },
      ],
    };