WordPress / block-theme-examples

A repository of feature examples for block themes.
50 stars 7 forks source link

Generated .asset.php Files Not Proper for Stylesheet Dependencies #14

Open timnolte opened 4 months ago

timnolte commented 4 months ago

So no where can I find where the ...asset.php that are generated, and then used for Stylesheet dependencies, are actually appropriate. The dependencies arrays are generally always empty and actually seem to be generated only based on JavaScript import/use dependencies. The @wordpress/dependency-extraction-webpack-plugin is actually not designed for stylesheets and is designed for JavaScript files.

The main problem is that in so many examples stylesheets are setup like:

function themeslug_assets() {
    $asset = include get_theme_file_path( 'public/css/screen.asset.php' );

    wp_enqueue_style(
        'themeslug-style',
        get_theme_file_uri( 'public/css/screen.css' ),
        $asset['dependencies'],
        $asset['version']
    );
}

The problem here is that that $asset array values are not populated properly and we need to actually manage those manually.

daotw commented 3 weeks ago

@timnolte in your example $asset['dependencies'] still doesn't work. We need it to work for dataviews and any React App in the admin area. In my links the authors use workarounds.