Description
I am not sure what I am doing wrong, but I had numerous plugins and themes already developed with wpack.io (version 5.x) with no issues. This time however whenever I try to enqueue my ts/scss into the backend nothing shows up. I debugged the issue and possibly solved it.
in my wpproject:
name:'referral',
entry: {
reftable:'./src/js/reftable.tsx',
reftablestyles:'./src/scss/main.scss',
},
in the plugins main file:
include_once 'vendor/autoload.php';
global $enq;
$enq = new \WPackio\Enqueue('dbireferral', 'dist', $ver, 'plugin', __FILE__);
and in the hook to enqueue scripts
add_action('admin_enqueue_scripts', function(){
global $enq;
$res = $enq->enqueue('referral', 'reftable', []);
$enq->enqueue('referral', 'reftablestyles', []);
});
So far pretty standard. However with the current setup it did not work for me. I debugged it and compared it with other plugins I had developed with wpack.io. The reason seems to be in wpacks main php file: Enqueue.php in the getAssets function
It loads the part of the manifest where the js files are all linked.
$enqueue = $manifest['wpackioEp'][ $entryPoint ];
For some reason the manifest looks different for my older plugins vs my current one. And it differs by adding an assets node around the js/css nodes. That way the above code in $enqueue doesn't give any results and nothing is enqueued:
wpackioEp:{ reftable: { assets: { js: [....] .... } } }
If in line 297 you change the enqueue variable it seems to work:
$enqueue = $manifest['wpackioEp'][ $entryPoint ]['assets'];
Maybe it has something to do with versions and how webpack delivers data. or maybe it is specific to backend. But someone should look at it, why this happens.