I am developing a WordPress that utilises gulp to build the frontend of the application (scss, js) files.
In my functions.php
I am using enqueue to load my css and js so that they can be used in the editor.
add_action( 'enqueue_block_editor_assets', function() {
wp_enqueue_style( 'editor-styling', get_theme_file_uri( '/dist/styles/main.css', __FILE__) );
wp_enqueue_script( 'editor-scripts', get_theme_file_uri( '/dist/scripts/main.js', __FILE__) );
} );
Running running a simple gulp
command I can do the above as the file will be named main.css
. However, I am facing an issue that when I use gulp --production
the style and javascript are suffixed with a random value.
For example my main.scss will (once I run the above command) turn into main-9acd4829.css
.
My question is, how can I get a file from a certain directory where file name like main<whatever>.css
.
I have tried using something such as
get_theme_file_uri(glob('/dist/styles/main*.css'), __FILE__)
However that returned null