How do I make it so that wp-scripts builds on plugin activation

You don’t, wp-scripts is a build step meant to run on a developers local machine or in a server build script such as a github action or CI/Continuous integration. It’s not meant to run on a live server. It requires Node JS and NPM as well as other dependencies.

It’s similar to running webpack or grunt to build a react application or compile assets, it’s not meant to happen on the server that hosts and serves the site.

This means that you’ll need to do one of the following:

  • Run WP Scripts beforehand on your machine and include the resulting built JS in your version control/git/zips/uploads
  • configure your code hosting service (e.g. github/bitbucket/office build server) to run WP Scripts and package the result into some sort of release that can be distributed

tech