Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] feature: this adds the vite integrity plugin to support assetsAreCurrent check #1415

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"sass": "^1.74.1",
"sql-formatter": "^4.0.2",
"vite": "^5.2.8",
"vite-plugin-manifest-sri": "^0.2.0",
"vue": "^2.7.16",
"vue-json-pretty": "^1.9.5",
"vue-router": "^3.6.5"
Expand Down
12 changes: 8 additions & 4 deletions public/build/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"resources/img/favicon.png": {
"file": "favicon.png",
"src": "resources/img/favicon.png"
"src": "resources/img/favicon.png",
"integrity": "sha384-tqnRilkeRgqFt3SUYaxuaQs14WOwuU8Gvk3sqRZmnyWZVhr1Kk19Ecr7dFMb4HZo"
},
"resources/js/app.js": {
"file": "app.js",
Expand All @@ -10,16 +11,19 @@
"isEntry": true,
"css": [
"app.css"
]
],
"integrity": "sha384-EV5vlraT2g7leIzueltC7I+UzR7uBT4ndQF5b1G9I+kUrQ4XL0DREuRw/XiU/U3P"
},
"resources/sass/styles-dark.scss": {
"file": "styles-dark.css",
"src": "resources/sass/styles-dark.scss",
"isEntry": true
"isEntry": true,
"integrity": "sha384-/sLOxh+NTFEdcZ8svIuVTv/lSL65X3QGIXhExXAhntQYWjiez1CQbv4ICbtwRfd8"
},
"resources/sass/styles.scss": {
"file": "styles.css",
"src": "resources/sass/styles.scss",
"isEntry": true
"isEntry": true,
"integrity": "sha384-4HOmv1E51xgqbUYzCYXaRXPRja5nEho6eq/L/CKs0LlidzTGNTk81VtCAHqLiYSC"
}
}
20 changes: 15 additions & 5 deletions resources/views/layout.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
@php
use Illuminate\Support\Facades\Vite;
use Illuminate\Foundation\Vite as ViteFoundation;

$viteDataSchemeLight = new ViteFoundation();
$viteDataSchemeLight->useStyleTagAttributes([
'data-scheme' => 'light',
]);

$viteDataSchemeDark = new ViteFoundation();
$viteDataSchemeDark->useStyleTagAttributes([
'data-scheme' => 'dark',
]);
Comment on lines +3 to +13
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is a better solution to this please tell me. currently its fairly hard (impossible) to add these kind of style tag attributes with the @Vite blade directive

@endphp
<!DOCTYPE html>
<html lang="en">

driesvints marked this conversation as resolved.
Show resolved Hide resolved
<head>
<!-- Meta Information -->
<meta charset="utf-8">
Expand All @@ -16,10 +28,8 @@
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=figtree:300,400,500,600" rel="stylesheet" />

<link rel="preload" as="style" href="{{ Vite::asset('resources/sass/styles.scss', 'vendor/horizon') }}" data-scheme="light" />
<link rel="stylesheet" href="{{ Vite::asset('resources/sass/styles.scss', 'vendor/horizon') }}" data-scheme="light" />
<link rel="preload" as="style" href="{{ Vite::asset('resources/sass/styles-dark.scss', 'vendor/horizon') }}" data-scheme="dark" />
<link rel="stylesheet" href="{{ Vite::asset('resources/sass/styles-dark.scss', 'vendor/horizon') }}" data-scheme="dark" />
{{ $viteDataSchemeLight('resources/sass/styles.scss', 'vendor/horizon') }}
{{ $viteDataSchemeDark('resources/sass/styles-dark.scss', 'vendor/horizon') }}
</head>
<body>
<div id="horizon" v-cloak>
Expand Down Expand Up @@ -147,6 +157,6 @@
window.Horizon = @json($horizonScriptVariables);
</script>

@vite('resources/js/app.js', 'vendor/horizon')
@vite('resources/js/app.js', 'vendor/horizon')
</body>
</html>
2 changes: 2 additions & 0 deletions vite.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import vue2 from "@vitejs/plugin-vue2";
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import manifestSRI from "vite-plugin-manifest-sri";

const config = defineConfig({
plugins: [
Expand All @@ -10,6 +11,7 @@ const config = defineConfig({
"resources/js/app.js",
]),
vue2(),
manifestSRI(),
],
resolve: {
alias: {
Expand Down