| @@ -208,8 +208,16 @@ | ||
| 208 | 208 | return $manifests[$manifest_path]; |
| 209 | 209 | } |
| 210 | 210 | function load_development_asset(object $manifest, string $entry, array $options, string $scope = ''): ?array |
| 211 | 211 | { |
| 212 | + if (string_ends_with($entry, '.css')) { | |
| 213 | + $src = development_asset_src($manifest, $entry); | |
| 214 | + if (!wp_register_style($options['handle'], $src, $options['css_dependencies'], null, $options['css_media'])) { | |
| 215 | + return null; | |
| 216 | + } | |
| 217 | + $assets = ['scripts' => [], 'styles' => [$options['handle']]]; | |
| 218 | + return filter_value('development_assets', $assets, $scope, $manifest, $entry, $options); | |
| 219 | + } | |
| 212 | 220 | register_vite_client_script($manifest); |
| 213 | 221 | inject_react_refresh_preamble($manifest); |
| 214 | 222 | $dependencies = array_values(array_unique(array_merge([VITE_CLIENT_HANDLE], $options['dependencies']))); |
| 215 | 223 | $src = development_asset_src($manifest, $entry); |
| @@ -230,8 +238,14 @@ | ||
| 230 | 238 | } |
| 231 | 239 | $item = $manifest->data->{$entry}; |
| 232 | 240 | $url = asset_url($manifest->dir); |
| 233 | 241 | $assets = ['scripts' => [], 'styles' => []]; |
| 242 | + if (string_ends_with($item->file, '.css')) { | |
| 243 | + if (wp_register_style($options['handle'], join_asset_url($url, $item->file), $options['css_dependencies'], null, $options['css_media'])) { | |
| 244 | + $assets['styles'][] = $options['handle']; | |
| 245 | + } | |
| 246 | + return filter_value('production_assets', $assets, $scope, $manifest, $entry, $options); | |
| 247 | + } | |
| 234 | 248 | if (!$options['css_only']) { |
| 235 | 249 | filter_script_tag($options['handle']); |
| 236 | 250 | if (wp_register_script($options['handle'], join_asset_url($url, $item->file), $options['dependencies'], null, $options['in_footer'])) { |
| 237 | 251 | $assets['scripts'][] = $options['handle']; |