Skip to content

Commit cc21b86

Browse files
authored
Merge pull request #2006 from hydephp/new-asset-system
[2.x] New asset system
2 parents 54012db + b38248c commit cc21b86

File tree

117 files changed

+5752
-17192
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

+5752
-17192
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -109,41 +109,6 @@ jobs:
109109
run: php monorepo/scripts/tests/${{ matrix.script }}.php
110110

111111

112-
build-hydefront-assets:
113-
114-
runs-on: ubuntu-latest
115-
needs: run-smoke-tests
116-
117-
steps:
118-
- uses: actions/checkout@v4
119-
120-
- name: Setup Node.js
121-
uses: actions/setup-node@v4
122-
with:
123-
cache: 'npm'
124-
125-
- name: Install Node.js dependencies
126-
working-directory: 'packages/hydefront'
127-
run: npm ci
128-
129-
- name: Build assets for production
130-
working-directory: 'packages/hydefront'
131-
run: npm run prod
132-
133-
- name: Upload artifacts
134-
uses: actions/upload-artifact@v4
135-
with:
136-
name: 'hydefront'
137-
path: 'packages/hydefront/dist'
138-
139-
- name: Commit changes
140-
uses: EndBug/add-and-commit@v9
141-
with:
142-
add: 'packages/hydefront/dist'
143-
message: 'Compile HydeFront assets for production'
144-
new_branch: compile-hydefront
145-
146-
147112
build-tailwindcss:
148113

149114
runs-on: ubuntu-latest
@@ -164,7 +129,7 @@ jobs:
164129
run: sed -i 's/\.\/vendor\/hyde\/framework\/resources\/views\/\*\*\/\*\.blade\.php/\.\/packages\/framework\/resources\/views\/\*\*\/\*\.blade\.php/' tailwind.config.js
165130

166131
- name: Build assets for production
167-
run: npm run prod
132+
run: npm run build
168133

169134
- name: Copy compiled app.css file to HydeFront dist folder
170135
run: cp _media/app.css packages/hydefront/dist/app.css

RELEASE_NOTES.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ This serves two purposes:
2626
- Added a `Feature::fromName()` enum helper in https://github.com/hydephp/develop/pull/1895
2727
- Added environment variable support for saving previews in https://github.com/hydephp/develop/pull/1996
2828
- Added support for specifying features in the YAML configuration in https://github.com/hydephp/develop/pull/1896
29+
- Added Vite as a build tool in https://github.com/hydephp/develop/pull/2010
2930
- **Added a new consolidated Asset API to better handle media files.**
3031
- Added several new fluent methods to the `MediaFile` class, like `getLink()`, `getLength()`, `getMimeType()`, etc.
3132
- Added new `HydeFront` facade to handle CDN links and Tailwind config injection.
3233
- Added method `Asset::exists()` has to check if a media file exists.
3334
- Added a `Hyde::assets()` method to get all media file instances in the site.
35+
- Added new `npm run build` command for compiling frontend assets with Vite
36+
- Added a Vite HMR support for the realtime compiler in https://github.com/hydephp/develop/pull/2016
37+
- Added Vite facade in https://github.com/hydephp/develop/pull/2016
38+
- Added a custom Blade-based heading renderer for Markdown conversions in https://github.com/hydephp/develop/pull/2047
3439

3540
### Changed
3641

@@ -88,6 +93,21 @@ This serves two purposes:
8893
- Media assets are now cached in the HydeKernel, giving a massive performance boost and making it easier to access the instances in https://github.com/hydephp/develop/pull/1917
8994
- Media file metadata is now lazy loaded and then cached in memory, providing performance improvements for files that may not be used in a build in https://github.com/hydephp/develop/pull/1933
9095
- We now use the much faster `CRC32` hashing algorithm instead of `MD5` for cache busting keys in https://github.com/hydephp/develop/pull/1918
96+
- **Replaced Laravel Mix with Vite for frontend asset compilation** in https://github.com/hydephp/develop/pull/2010
97+
- **Breaking:** You must now use `npm run build` to compile your assets, instead of `npm run prod`
98+
- Bundled assets are now compiled directly into the `_media` folder, and will not be copied to the `_site/media` folder by the NPM command in https://github.com/hydephp/develop/pull/2011
99+
- The realtime compiler now only serves assets from the media source directory (`_media`), and no longer checks the site output directory (`_site/media`) in https://github.com/hydephp/develop/pull/2012
100+
- **Breaking:** Replaced `--run-dev` and `--run-prod` build command flags with a single `--run-vite` flag that uses Vite to build assets in https://github.com/hydephp/develop/pull/2013
101+
- Moved the Vite build step to run before the site build to prevent duplicate media asset transfers in https://github.com/hydephp/develop/pull/2013
102+
- Ported the HydeSearch plugin used for the documentation search to be an Alpine.js implementation in https://github.com/hydephp/develop/pull/2029
103+
- Renamed Blade component `hyde::components.docs.search-widget` to `hyde::components.docs.search-modal` in https://github.com/hydephp/develop/pull/2029
104+
- Added support for customizing the search implementation by creating a `resources/js/HydeSearch.js` file in https://github.com/hydephp/develop/pull/2031
105+
- Normalized default Tailwind Typography Prose code block styles to match Torchlight's theme, ensuring consistent styling across Markdown and Torchlight code blocks in https://github.com/hydephp/develop/pull/2036.
106+
- Extracted CSS component partials in HydeFront in https://github.com/hydephp/develop/pull/2038
107+
- Replaced HydeFront styles with Tailwind in https://github.com/hydephp/develop/pull/2024
108+
- Markdown headings are now compiled using our custom Blade-based heading renderer in https://github.com/hydephp/develop/pull/2047
109+
- The `id` attributes for heading permalinks have been moved from the anchor to the heading element in https://github.com/hydephp/develop/pull/2052
110+
- Colored Markdown blockquotes are now rendered using Blade and TailwindCSS, this change is not visible in the rendered result, but the HTML output has changed in https://github.com/hydephp/develop/pull/2056
91111

92112
### Deprecated
93113

@@ -97,6 +117,8 @@ This serves two purposes:
97117

98118
- Breaking: Removed the build task `\Hyde\Framework\Actions\PostBuildTasks\GenerateSearch` (see upgrade guide below)
99119
- Breaking: Removed the deprecated `\Hyde\Framework\Services\BuildService::transferMediaAssets()` method (see upgrade guide below)
120+
- Breaking: Removed the `DocumentationPage::getTableOfContents()` method as we now use Blade to generate the table of contents in https://github.com/hydephp/develop/pull/2045
121+
- Breaking: Removed the `DocumentationPage::hasTableOfContents()` method as it is now unused by the framework in https://github.com/hydephp/develop/pull/2006
100122
- Removed the deprecated global `unslash()` function, replaced with the namespaced `\Hyde\unslash()` function in https://github.com/hydephp/develop/pull/1754
101123
- Removed the deprecated `BaseUrlNotSetException` class, with the `Hyde::url()` helper now throwing `BadMethodCallException` if no base URL is set in https://github.com/hydephp/develop/pull/1760
102124
- Removed: The deprecated `PostAuthor::getName()` method is now removed (use `$author->name`) in https://github.com/hydephp/develop/pull/1782
@@ -109,15 +131,37 @@ This serves two purposes:
109131
- Removed `Hyde::mediaLink()` method replaced by `Hyde::asset()` in https://github.com/hydephp/develop/pull/1932
110132
- Removed `Hyde::mediaPath()` method replaced by `MediaFile::sourcePath()` in https://github.com/hydephp/develop/pull/1911
111133
- Removed `Hyde::siteMediaPath()` method replaced by `MediaFile::outputPath()` in https://github.com/hydephp/develop/pull/1911
134+
- Removed Laravel Mix as a dependency in https://github.com/hydephp/develop/pull/2010 (replaced with Vite)
135+
- **Breaking:** Removed `npm run prod` command (replaced with `npm run build`)
136+
- Removed CDN include for the HydeSearch plugin replaced by Alpine.js implementation in https://github.com/hydephp/develop/pull/2029
137+
- This also removes the `<x-hyde::docs.search-input />` and `<x-hyde::docs.search-scripts />` Blade components, replaced by the new `<x-hyde::docs.hyde-search />` component.
138+
- Removed the `.torchlight-enabled` CSS class in https://github.com/hydephp/develop/pull/2036.
139+
- Removed The `hyde.css` file from HydeFront in https://github.com/hydephp/develop/pull/2037 as all styles were refactored to Tailwind in https://github.com/hydephp/develop/pull/2024.
140+
- Removed the `MarkdownService::withPermalinks` method in https://github.com/hydephp/develop/pull/2047
141+
- Removed the `MarkdownService::canEnablePermalinks` method in https://github.com/hydephp/develop/pull/2047
112142

113143
### Fixed
114144

115145
- Added missing collection key types in Hyde facade method annotations in https://github.com/hydephp/develop/pull/1784
146+
- The `app.js` file will now only be compiled if it has scripts in https://github.com/hydephp/develop/pull/2028
116147

117148
### Security
118149

119150
- in case of vulnerabilities.
120151

152+
### Package updates
153+
154+
#### Realtime Compiler
155+
156+
- Simplified the asset file locator to only serve files from the media source directory in https://github.com/hydephp/develop/pull/2012
157+
- Added Vite HMR support in https://github.com/hydephp/develop/pull/2016
158+
159+
#### HydeFront
160+
161+
- Removed all Sass styles after porting everything to Tailwind in https://github.com/hydephp/develop/pull/2024
162+
- Removed the `hyde.css` file in https://github.com/hydephp/develop/pull/2037 as all its styles were refactored to Tailwind in https://github.com/hydephp/develop/pull/2024
163+
- Extracted CSS component partials in https://github.com/hydephp/develop/pull/2038
164+
121165
### Upgrade Guide
122166

123167
Please see the "Breaking changes & upgrade guide" section below for more information.
@@ -464,6 +508,82 @@ Hyperlinks::isRemote($source);
464508

465509
This change was implemented in https://github.com/hydephp/develop/pull/1883. Make sure to update any instances of `FeaturedImage::isRemote()` in your codebase to ensure compatibility with HydePHP v2.0.
466510

511+
## New Asset System
512+
513+
### Abstract
514+
515+
The new asset system is a complete rewrite of the HydeFront asset handling system, replacing Laravel Mix with Vite, and favouring Blade-based components with Tailwind classes over CSS partials and custom stylesheets.
516+
517+
### Enhancements
518+
519+
- **Replaced Laravel Mix with Vite for frontend asset compilation.** ([#2010], [#2011], [#2012], [#2013], [#2016], [#2021])
520+
- Bundled assets are now compiled directly into the `_media` folder.
521+
- The realtime compiler now only serves assets from the media source directory (`_media`).
522+
- Added a new `npm run build` command for compiling frontend assets with Vite.
523+
- Added Vite facade for Blade templates.
524+
- Added Vite Hot Module Replacement (HMR) support to the realtime compiler.
525+
- Build command now uses Vite to compile assets when the `--run-vite` flag is passed.
526+
527+
- **Improved HydeFront integration.** ([#2024], [#2029], [#2031], [#2036], [#2037], [#2038], [#2039])
528+
- HydeFront styles are now refactored into Tailwind.
529+
- HydeFront now acts as a component library with granular Tailwind styles in `app.css`.
530+
- HydeSearch plugin ported to Alpine.js, improving performance and customizability.
531+
- Normalized Tailwind Typography Prose code block styles to match Torchlight.
532+
- Extracted CSS component partials in HydeFront.
533+
- Removed `hyde.css` from HydeFront, as all styles are now included in `app.css`.
534+
535+
- **Implemented a custom Blade-based heading renderer for Markdown.** ([#2047], [#2052])
536+
- Improves permalink handling and customization options.
537+
- `id` attributes for heading permalinks have been moved from the anchor to the heading element.
538+
- **Colored Markdown blockquotes are now rendered using Blade and Tailwind CSS.** ([#2056])
539+
- The `app.js` file will now only be compiled if it has scripts. ([#2028])
540+
541+
542+
### Breaking Changes
543+
544+
- Replaced Laravel Mix with Vite. ([#2010])
545+
- You must now use `npm run build` to compile your assets, instead of `npm run prod`.
546+
- Removed `--run-dev` and `--run-prod` build command flags, replaced by `--run-vite`. ([#2013])
547+
- Removed `DocumentationPage::getTableOfContents()` method. Table of contents are now generated using a Blade component. ([#2045])
548+
- Removed `hyde.css` from HydeFront, requiring recompilation of assets if you were extending it. ([#2037])
549+
- Changed how HydeFront is included in projects. Instead of separate `hyde.css` and `app.css`, all styles are now in `app.css`. ([#2024])
550+
551+
552+
### Removals
553+
554+
- Removed Laravel Mix as a dependency. ([#2010])
555+
- Removed `npm run prod` command. ([#2010])
556+
- Removed CDN include for HydeSearch plugin. ([#2029])
557+
- Removed the `<x-hyde::docs.search-input />` and `<x-hyde::docs.search-scripts />` Blade components, replaced by `<x-hyde::docs.hyde-search />`. ([#2029])
558+
- Removed the `.torchlight-enabled` CSS class. ([#2036])
559+
- Removed the `MarkdownService::withPermalinks` and `MarkdownService::canEnablePermalinks` methods. ([#2047])
560+
561+
562+
### Blade-based table of contents generator
563+
564+
The way we generate table of contents for documentation pages have been changed from a helper method to a Blade component.
565+
566+
This new system is much easier to customize and style, and is up to 40 times faster than the old system.
567+
568+
See https://github.com/hydephp/develop/pull/2045 for more information.
569+
570+
#### Scope
571+
572+
The likelihood of impact is low, but if any of the following are true, you may need to update your code:
573+
574+
- If you have used the `Hyde\Framework\Actions\GeneratesTableOfContents` class in custom code, you will likely need to update that code for the rewritten class.
575+
- If you have published the `resources/views/components/docs/sidebar-item.blade.php` component, you will need to update it to call the new component instead of the old generator rendering.
576+
- If you have called the now removed `getTableOfContents` method of the `DocumentationPage` class in custom code, you will need to update that usage as to possibly call the new Blade component directly, depending on your use case.
577+
- If you have called the now removed `hasTableOfContents` method of the `DocumentationPage` class in custom code you will need to replace the method call with `Config::getBool('docs.sidebar.table_of_contents.enabled', true)`
578+
579+
#### Changes
580+
- Adds a new `resources/views/components/docs/table-of-contents.blade.php` component containing the structure and styles for the table of contents
581+
- Rewrites the `GeneratesTableOfContents` class to use a custom implementation instead of using CommonMark
582+
- The `execute` method of the `GeneratesTableOfContents` class now returns an array of data, instead of a string of HTML. This data should be fed into the new component
583+
- Removed the `table-of-contents.css` file as styles are now made using Tailwind
584+
- Removed the `heading-permalinks.css` file as styles are now made using Tailwind
585+
- Removed the `blockquotes.css` file as styles are now made using Tailwind
586+
467587
## New features
468588

469589
<!-- Editors note: Todo: Maybe move to the relevant docs... -->

_ide_helper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Asset extends \Hyde\Facades\Asset {}
3737
class Author extends \Hyde\Facades\Author {}
3838
class Features extends \Hyde\Facades\Features {}
3939
class Config extends \Hyde\Facades\Config {}
40+
class Vite extends \Hyde\Facades\Vite {}
4041
/** @mixin \Illuminate\Filesystem\Filesystem */
4142
class Filesystem extends \Hyde\Facades\Filesystem {}
4243
class DataCollection extends \Hyde\Support\DataCollection {}

0 commit comments

Comments
 (0)