Skip to content

Build-time scripts -- what plugin to run them and what environment do they run in? #20530

Discussion options

You must be logged in to vote

Hi @stuvjordan-uroc,

Your questions are quite common for people starting with Vite and bundlers, so no worries — happy to clarify.

  1. Is rollup-plugin-command the right plugin to run scripts at build time?
    You can use rollup-plugin-command to run commands during the Rollup build, and since Vite uses Rollup under the hood for production builds, it works—but it’s not the only or necessarily the best way.

A simpler and more direct approach is to write a custom Vite plugin that runs your code during build hooks such as buildStart. This lets you execute arbitrary Node.js code directly, without depending on extra plugins.

Example of a simple custom Vite plugin to generate assets at build time:

/…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@stuvjordan-uroc
Comment options

Answer selected by stuvjordan-uroc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants