Skip to content

Commit df27ad9

Browse files
[5.x] feature: this adds the vite integrity plugin to support assetsAreCurrent check (#1415)
* feature: this adds the vite integrity plugin to support assetsAreCurrent check fix schema -> scheme compile assets * Update resources/views/layout.blade.php --------- Co-authored-by: Dries Vints <[email protected]>
1 parent 3c6661d commit df27ad9

File tree

5 files changed

+38
-9
lines changed

5 files changed

+38
-9
lines changed

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"sass": "^1.74.1",
2424
"sql-formatter": "^4.0.2",
2525
"vite": "^5.2.8",
26+
"vite-plugin-manifest-sri": "^0.2.0",
2627
"vue": "^2.7.16",
2728
"vue-json-pretty": "^1.9.5",
2829
"vue-router": "^3.6.5"

public/build/manifest.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"resources/img/favicon.png": {
33
"file": "favicon.png",
4-
"src": "resources/img/favicon.png"
4+
"src": "resources/img/favicon.png",
5+
"integrity": "sha384-tqnRilkeRgqFt3SUYaxuaQs14WOwuU8Gvk3sqRZmnyWZVhr1Kk19Ecr7dFMb4HZo"
56
},
67
"resources/js/app.js": {
78
"file": "app.js",
@@ -10,16 +11,19 @@
1011
"isEntry": true,
1112
"css": [
1213
"app.css"
13-
]
14+
],
15+
"integrity": "sha384-EV5vlraT2g7leIzueltC7I+UzR7uBT4ndQF5b1G9I+kUrQ4XL0DREuRw/XiU/U3P"
1416
},
1517
"resources/sass/styles-dark.scss": {
1618
"file": "styles-dark.css",
1719
"src": "resources/sass/styles-dark.scss",
18-
"isEntry": true
20+
"isEntry": true,
21+
"integrity": "sha384-/sLOxh+NTFEdcZ8svIuVTv/lSL65X3QGIXhExXAhntQYWjiez1CQbv4ICbtwRfd8"
1922
},
2023
"resources/sass/styles.scss": {
2124
"file": "styles.css",
2225
"src": "resources/sass/styles.scss",
23-
"isEntry": true
26+
"isEntry": true,
27+
"integrity": "sha384-4HOmv1E51xgqbUYzCYXaRXPRja5nEho6eq/L/CKs0LlidzTGNTk81VtCAHqLiYSC"
2428
}
2529
}

resources/views/layout.blade.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
@php
22
use Illuminate\Support\Facades\Vite;
3+
use Illuminate\Foundation\Vite as ViteFoundation;
4+
5+
$viteDataSchemeLight = new ViteFoundation();
6+
$viteDataSchemeLight->useStyleTagAttributes([
7+
'data-scheme' => 'light',
8+
]);
9+
10+
$viteDataSchemeDark = new ViteFoundation();
11+
$viteDataSchemeDark->useStyleTagAttributes([
12+
'data-scheme' => 'dark',
13+
]);
314
@endphp
415
<!DOCTYPE html>
516
<html lang="en">
@@ -16,10 +27,8 @@
1627
<link rel="preconnect" href="https://fonts.bunny.net">
1728
<link href="https://fonts.bunny.net/css?family=figtree:300,400,500,600" rel="stylesheet" />
1829

19-
<link rel="preload" as="style" href="{{ Vite::asset('resources/sass/styles.scss', 'vendor/horizon') }}" data-scheme="light" />
20-
<link rel="stylesheet" href="{{ Vite::asset('resources/sass/styles.scss', 'vendor/horizon') }}" data-scheme="light" />
21-
<link rel="preload" as="style" href="{{ Vite::asset('resources/sass/styles-dark.scss', 'vendor/horizon') }}" data-scheme="dark" />
22-
<link rel="stylesheet" href="{{ Vite::asset('resources/sass/styles-dark.scss', 'vendor/horizon') }}" data-scheme="dark" />
30+
{{ $viteDataSchemeLight('resources/sass/styles.scss', 'vendor/horizon') }}
31+
{{ $viteDataSchemeDark('resources/sass/styles-dark.scss', 'vendor/horizon') }}
2332
</head>
2433
<body>
2534
<div id="horizon" v-cloak>
@@ -147,6 +156,6 @@
147156
window.Horizon = @json($horizonScriptVariables);
148157
</script>
149158

150-
@vite('resources/js/app.js', 'vendor/horizon')
159+
@vite('resources/js/app.js', 'vendor/horizon')
151160
</body>
152161
</html>

vite.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import vue2 from "@vitejs/plugin-vue2";
22
import { defineConfig } from "vite";
33
import laravel from "laravel-vite-plugin";
4+
import manifestSRI from "vite-plugin-manifest-sri";
45

56
const config = defineConfig({
67
plugins: [
@@ -10,6 +11,7 @@ const config = defineConfig({
1011
"resources/js/app.js",
1112
]),
1213
vue2(),
14+
manifestSRI(),
1315
],
1416
resolve: {
1517
alias: {

0 commit comments

Comments
 (0)