I have an implementation in sage10 which is using the following code to pass some variables to a javascript:
bundle('foo')->enqueue()->localize('fooAjax', ['ajaxurl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('foo_check_nonce')]);
Is there a way to achieve that with vite?