Javascript file 404 in wp-admin not using the script path in assets.json with version number

Hi,

I am using Sage 8.4.2 with Gulp 3.9.1.

I have some custom buttons in the wp rich text editor which create shortcodes to wrap text. For this i have a shortcodes.php and a shortcodes.js file.

I have compiled my theme using gulp --production, and the assets are compiling as you’d expect - the dist folder contains an assets.json file which looks like this:

{
  "customizer.js": "customizer-2d71a5cf56.js",
  "jquery.js": "jquery-a72f8de744.js",
  "main.css": "main-932bb09459.css",
  "main.js": "main-a65a2e3f8f.js",
  "shortcodes.js": "shortcodes-e17d404aeb.js"
}

and the compiled file is found at dist/scripts/shortcodes-e17d404aeb.js

when upload the theme, everything works great, except the buttons do not show, and i am getting a 404 for the file shortcodes.js

For some reason it’s looking for shortcodes.js and not finding it, instead of translating through assets.json (if that’s what is supposed to happen).

here is the function in shortcodes.php where it references the js file:

function add_shortcode_plugin( $plugin_array ) {
	$plugin_array['intro'] = get_template_directory_uri() . '/dist/scripts/shortcodes.js';
	$plugin_array['subheader'] = get_template_directory_uri() . '/dist/scripts/shortcodes.js';
	$plugin_array['green_button'] = get_template_directory_uri() . '/dist/scripts/shortcodes.js';
	return $plugin_array;
}

the thing is, if i change this function to:

function add_shortcode_plugin( $plugin_array ) {
	$plugin_array['intro'] = get_template_directory_uri() . '/dist/scripts/shortcodes-e17d404aeb.js';
	$plugin_array['subheader'] = get_template_directory_uri() . '/dist/scripts/shortcodes-e17d404aeb.js';
	$plugin_array['green_button'] = get_template_directory_uri() . '/dist/scripts/shortcodes-e17d404aeb.js';
	return $plugin_array;
}

which is what i have done, everything works: no 404, buttons show in tinymce etc.

But this can’t be the right way to go about it. What am i doing wrong?