Skip to content

Commit 4600227

Browse files
authored
✨ Bud to ViteJS and Acorn v5 (#33)
2 parents 6a2f54b + e6d983e commit 4600227

File tree

117 files changed

+11526
-16024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+11526
-16024
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ DB_ROOT_PASSWORD='root_password'
1313

1414
WP_ENV='development'
1515
WP_HOME='http://127.0.0.1:8000'
16+
APP_URL==${WP_HOME}
1617
WP_SITEURL="${WP_HOME}/wp"
1718

1819
# Generate your keys here: https://roots.io/salts.html

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,4 @@ jobs:
7474
- name: Build and compile assets
7575
run: |
7676
pnpm build
77-
cat public/dist/entrypoints.json
78-
cat public/dist/manifest.json
79-
cat public/dist/theme.json
77+
cat public/build/manifest.json

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ npm-debug.log
2323
yarn-error.log
2424

2525
# Build
26-
public/dist/*
26+
public/build/*
27+
public/hot
2728

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
1. Install Node dependencies:
1414

1515
```bash
16-
yarn
16+
pnpm install
17+
1718
```
1819

1920
2. Install Composer dependencies:
@@ -60,5 +61,5 @@ DB_PASSWORD='database_password'
6061
### Start the development server
6162

6263
```bash
63-
wp server --port=8000
64+
docker compose up -d
6465
```

app/Providers/AssetsServiceProvider.php

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,53 @@
22

33
namespace App\Providers;
44

5+
use Illuminate\Support\Facades\Vite;
56
use Roots\Acorn\Sage\SageServiceProvider;
67

7-
use function Roots\bundle;
8-
98
class AssetsServiceProvider extends SageServiceProvider
109
{
1110
public function register(): void
1211
{
1312
add_action('wp_enqueue_scripts', function (): void {
14-
bundle('app')->enqueue();
15-
1613
remove_action('wp_body_open', 'wp_global_styles_render_svg_filters');
1714
}, 100);
1815

19-
add_action('enqueue_block_editor_assets', function (): void {
20-
bundle('editor')->enqueue();
21-
}, 100);
16+
add_filter('block_editor_settings_all', function ($settings) {
17+
$style = Vite::asset('resources/css/editor.css');
18+
19+
$settings['styles'][] = [
20+
'css' => "@import url('{$style}')",
21+
];
22+
23+
return $settings;
24+
});
2225

23-
/**
24-
* Use theme.json from the build directory
25-
*
26-
* @param string $path
27-
* @param string $file
28-
* @return string
29-
*/
30-
add_filter('theme_file_path', function (string $path, string $file): string {
31-
if ($file === 'theme.json') {
32-
return public_path() . '/dist/theme.json';
26+
add_filter('admin_head', function () {
27+
if (! get_current_screen()?->is_block_editor()) {
28+
return;
3329
}
3430

35-
return $path;
31+
$dependencies = json_decode(Vite::content('editor.deps.json'));
32+
33+
foreach ($dependencies as $dependency) {
34+
if (! wp_script_is($dependency)) {
35+
wp_enqueue_script($dependency);
36+
}
37+
}
38+
39+
echo Vite::withEntryPoints([
40+
'resources/js/editor.ts',
41+
])->toHtml();
42+
});
43+
44+
add_filter('theme_file_path', function ($path, $file) {
45+
return $file === 'theme.json'
46+
? public_path('build/assets/theme.json')
47+
: $path;
3648
}, 10, 2);
3749

3850
add_filter('wp_theme_json_data_default', function (\WP_Theme_JSON_Data $themeJson): \WP_Theme_JSON_Data {
39-
$themeJsonFile = public_path('/dist/theme.json');
51+
$themeJsonFile = public_path('/build/assets/theme.json');
4052
if (!file_exists($themeJsonFile)) {
4153
return $themeJson;
4254
}
@@ -46,8 +58,7 @@ public function register(): void
4658
return $themeJson;
4759
}
4860

49-
$mergedData = array_merge($themeJson->get_data(), $decodedData);
50-
return new \WP_Theme_JSON_Data($mergedData, 'default');
61+
return new \WP_Theme_JSON_Data($decodedData, 'default');
5162
}, 100);
5263
}
5364
}

app/Providers/BlockAssetsServiceProvider.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
namespace App\Providers;
66

7-
use Illuminate\Support\ServiceProvider;
7+
use Roots\Acorn\Sage\SageServiceProvider;
88
use Symfony\Component\Finder\Finder;
99

10-
use function Roots\bundle;
11-
12-
class BlockAssetsServiceProvider extends ServiceProvider
10+
class BlockAssetsServiceProvider extends SageServiceProvider
1311
{
1412
public function register(): void
1513
{
@@ -26,7 +24,7 @@ public function register(): void
2624
continue;
2725
}
2826
if (has_block($block, $postContent)) {
29-
bundle("blocks/{$block}")->enqueue();
27+
//bundle("blocks/{$block}")->enqueue();
3028
}
3129
}
3230

@@ -36,7 +34,7 @@ public function register(): void
3634

3735
add_action('wpcf7_enqueue_styles', function () {
3836
if (has_block('inr/wpcf7')) {
39-
bundle('components/wpcf7')->enqueue();
37+
//bundle('components/wpcf7')->enqueue();
4038
}
4139
});
4240

@@ -57,7 +55,7 @@ private function getAvailableBlocks(): array
5755
{
5856
$typesBlocks = (new Finder())->directories()->in(
5957
ABSPATH . '../../resources/',
60-
)->path('/scripts|styles/')->depth('== 1')->name('blocks');
58+
)->path('/js|css/')->depth('== 1')->name('blocks');
6159
$typesBlocks = (new Finder())->directories()->in(
6260
iterator_to_array($typesBlocks->getIterator())
6361
)->depth('0');
@@ -85,7 +83,7 @@ private function findCustomClass(string $haystackBlock, array $parsedBlocks): vo
8583

8684
foreach ($block['attrs'] as $attr) {
8785
if ($attr === $haystackBlock && isset($block['attrs']['className'])) {
88-
bundle('blocks/custom-class/' . $block['attrs']['className'])->enqueue();
86+
//bundle('blocks/custom-class/' . $block['attrs']['className'])->enqueue();
8987
}
9088
}
9189

bud.config.ts

Lines changed: 0 additions & 129 deletions
This file was deleted.

composer.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,28 @@
4242
"minimum-stability": "dev",
4343
"require": {
4444
"php": ">=8.3",
45-
"blade-ui-kit/blade-heroicons": "^2.5",
46-
"blade-ui-kit/blade-icons": "^1.7",
45+
"blade-ui-kit/blade-heroicons": "^2.6",
46+
"blade-ui-kit/blade-icons": "^1.8",
4747
"composer/installers": "^2.2",
4848
"inrage/acorn-mail": "^1.0",
4949
"log1x/acorn-disable-media-pages": "^1.0",
5050
"oscarotero/env": "^2.1",
51-
"roots/acorn": "^4.3",
51+
"roots/acorn": "^5.0",
5252
"roots/acorn-prettify": "^1.0",
5353
"roots/bedrock-autoloader": "^1.0",
5454
"roots/bedrock-disallow-indexing": "^2.0",
55-
"roots/wordpress": "6.7.2",
55+
"roots/wordpress": "6.8.1",
5656
"roots/wp-config": "1.0.0",
57-
"roots/wp-password-bcrypt": "1.2.0",
5857
"vlucas/phpdotenv": "^5.5",
5958
"wpackagist-plugin/redis-cache": "^2.5",
60-
"wpackagist-plugin/safe-svg": "^2.2"
59+
"wpackagist-plugin/safe-svg": "^2.3"
6160
},
6261
"require-dev": {
63-
"johnbillion/query-monitor": "^3.16",
64-
"laravel/pint": "^1.18",
62+
"johnbillion/query-monitor": "^3.17",
63+
"laravel/pint": "^1.21",
6564
"phpcompatibility/php-compatibility": "^9.3",
6665
"roave/security-advisories": "dev-latest",
67-
"spatie/laravel-ignition": "^2.8",
66+
"spatie/laravel-ignition": "^2.9",
6867
"squizlabs/php_codesniffer": "^3.7.1"
6968
},
7069
"config": {

0 commit comments

Comments
 (0)