How to have frontend .js files processed and served with @wordpress/scripts?

I’m using @wordpress/scripts to create a Gutenberg block. The block will need to run some javascript on the frontend and I’m wondering what the best way is to get that script file to pass through Babel like the backend script.

I know I can use wp_enqueue_script to get a script file to show up on the frontend. But I’m wondering if there is a way to have a script file that gets processed through Babel, just like the block’s source code, and I can point wp_enqueue_script to a file in the build folder that contains the minified ES5 version of the frontend code.

When I do wp-scripts start index.js scripts.js it works as expected but I’m trying to figure out how to do it with wp-scripts build.

Source link