Support

Account

Home Forums Gutenberg Block script error Reply To: Block script error

  • Thanks for the reply @mnajlat.
    I added product-grid.asset.php to the same directory as the block.json file with the following array:

    return array(
      'handle'       => 'product-grid-script',
      'dependencies' => array(''),
      'version'      => '1.0',
    );

    Then I added the following in the block.json file:
    "script": "file:./product-grid.js",

    This got rid of the error but product-grid.js doesn’t load. Do you see any issues with what I added?

    I did find a work around by registering the script on init using:
    wp_register_script( 'product-grid-script', get_template_directory_uri() . '/acf-blocks/products/product-grid/product-grid.js', array(), '1.0.0', true );
    Then in block.json I call the script’s handle:
    "script": "product-grid-script",