• Resolved joshrouwhorst

    (@joshrouwhorst)


    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.

Viewing 1 replies (of 1 total)
  • Thread Starter joshrouwhorst

    (@joshrouwhorst)

    Nevermind, I must have been doing something wrong. I was able to get it to work by running wp-scripts build ./src/index.js ./src/scripts.js

Viewing 1 replies (of 1 total)
  • The topic ‘How to have frontend .js files processed and served with @wordpress/scripts?’ is closed to new replies.