Closed caendesilva closed 3 hours ago
Based on the provided code snippets, it appears that the app.js
file is not strictly necessary in the current HydePHP setup. Here's my analysis:
app.js
file is essentially empty, containing only a comment:/*
* This is the main JavaScript used by Vite to build the app.js file.
*/
{{-- Alpine.js --}}
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.10.3/dist/cdn.min.js" integrity="sha256-gOkV4d9/FmMNEkjOzVlyM2eNAWSUXisT+1RbMTTIgXI=" crossorigin="anonymous"></script>
app.js
in its build process: input: [
resolve(__dirname, 'resources/assets/app.js'),
resolve(__dirname, 'resources/assets/app.css')
],
app.js
just checks that it exists and contains a comment:
public function testLaravelMixResourcesArePresent()
{
$this->assertFileExists(Hyde::path('resources/assets/app.css'));
$this->assertFileExists(Hyde::path('resources/assets/app.js'));
$this->assertFileContainsString('@tailwind base;', Hyde::path('resources/assets/app.css'));
$this->assertFileContainsString('@tailwind components;', Hyde::path('resources/assets/app.css'));
$this->assertFileContainsString('@tailwind utilities;', Hyde::path('resources/assets/app.css'));
$this->assertFileContainsString('This is the main JavaScript', Hyde::path('resources/assets/app.js'));
}
Recommendation:
The app.js
file could be safely removed since:
To remove it:
resources/assets/app.js
However, you might want to keep the empty file as a convenience for users who want to add their own JavaScript in the future, since the build pipeline is already set up to handle it. This follows Hyde's philosophy of being ready for customization while not requiring it.
Okay, in https://github.com/hydephp/develop/pull/2028 we will keep the app.js in resources to keep it easily available, but we won't compile the empty file. So that resolves the annoyance here.
Do we actually need the app.js file? We just use Alpine at the moment, so it's empty by default. The app.css file at least loads Tailwind.