Roots Discourse

Custom JS not found and missing in dist

hello everyone,

I have this external JS, called let’ say myfile.js.

I have:

  1. updated config.json in resources path:
"entry": {
    "main": [
      "./scripts/main.js",
      "./styles/main.scss"
    ],
    "customizer": [
      "./scripts/customizer.js"
    ],
    "myfile": [
      "./scripts/util/myfile.js"
    ]
  },
  1. imported into setup.php
...
add_action('wp_enqueue_scripts', function () {
    wp_enqueue_style('sage/main.css', asset_path('styles/main.css'), false, null);
    wp_enqueue_script('sage/main.js', asset_path('scripts/main.js'), ['jquery'], null, true);
    wp_enqueue_script('sage/myfile', asset_path('scripts/util/myfile.js'), ['jquery'], null, true);
...

I yarn run start and re-build everything BUT the file cannot be found in the DIST directory.

https://localhost:3000/app/themes/MY_THEME/dist/scripts/util/myfile.js is missing…

and therefore, if I try to call the class whiting a finalize() function, it fails…

any hint?
ty!

Hi, move your custom js script file to main script folder and change the paths in config.js and setup.php.

    "myfile": [
      "./scripts/myfile.js"
    ]
wp_enqueue_script('sage/myfile', asset_path('scripts/myfile.js'), ['jquery'], null, true);

hi, nope, same error :frowning:
again

https://localhost:3000/app/themes/MY_THEME/dist/scripts/myfile.js not found

sounds weird, none can help me :smiley:
??? :frowning: