Przeglądaj źródła

Updated Vite: https://laracasts.com/discuss/channels/laravel/unable-to-locate-file-in-vite-manifest-resourcescssappcss?page=1&replyId=813810

procodergw 2 lat temu
rodzic
commit
e2f9501c1d
4 zmienionych plików z 40 dodań i 38 usunięć
  1. 1 0
      resources/js/app.js
  2. 1 1
      resources/views/layouts/app.blade.php
  3. 4 33
      vite.config.js
  4. 34 4
      vite.config.test.js

+ 1 - 0
resources/js/app.js

@@ -1,4 +1,5 @@
 import './bootstrap';
+import '../css/app.css';
 
 import Alpine from 'alpinejs';
 

+ 1 - 1
resources/views/layouts/app.blade.php

@@ -11,7 +11,7 @@
         <link rel="stylesheet" href="https://fonts.bunny.net/css2?family=Nunito:wght@400;600;700&display=swap">
 
         <!-- Scripts -->
-        @vite(['resources/css/app.css', 'resources/js/app.js'])
+        @vite(['resources/js/app.js'])
     </head>
     <body class="font-sans antialiased">
         <div class="min-h-screen bg-gray-100">

+ 4 - 33
vite.config.js

@@ -1,43 +1,14 @@
 import laravel from 'laravel-vite-plugin'
 import { defineConfig } from 'vite'
-import fs from 'fs';
-import { homedir } from 'os'
-import { resolve } from 'path'
-
-let host = 'orion4.test'
 
 export default defineConfig({
     plugins: [
         laravel({
-            input: 'resources/js/app.js',
+            input: [
+                'resources/css/app.css',
+                'resources/js/app.js',
+            ],
             refresh: true,
         }),
     ],
-
-    server: detectServerConfig(host),
 })
-
-function detectServerConfig(host) {
-    let keyPath = resolve(homedir(), `.config/valet/Certificates/${host}.key`)
-    let certificatePath = resolve(homedir(), `.config/valet/Certificates/${host}.crt`)
-
-    if (!fs.existsSync(keyPath)) {
-        return {}
-    }
-
-    if (!fs.existsSync(certificatePath)) {
-        return {}
-    }
-
-    return {
-        hmr: {host},
-        host,
-        https: {
-            key: fs.readFileSync(keyPath),
-            cert: fs.readFileSync(certificatePath),
-        },
-        watch: {
-            usePolling: true,
-        }
-    }
-}

+ 34 - 4
vite.config.test.js

@@ -1,14 +1,44 @@
+
 import laravel from 'laravel-vite-plugin'
 import { defineConfig } from 'vite'
+import fs from 'fs';
+import { homedir } from 'os'
+import { resolve } from 'path'
+
+let host = 'orion4.test'
 
 export default defineConfig({
     plugins: [
         laravel({
-            input: [
-                'resources/css/app.css',
-                'resources/js/app.js',
-            ],
+            input: 'resources/js/app.js',
             refresh: true,
         }),
     ],
+
+    server: detectServerConfig(host),
 })
+
+function detectServerConfig(host) {
+    let keyPath = resolve(homedir(), `.config/valet/Certificates/${host}.key`)
+    let certificatePath = resolve(homedir(), `.config/valet/Certificates/${host}.crt`)
+
+    if (!fs.existsSync(keyPath)) {
+        return {}
+    }
+
+    if (!fs.existsSync(certificatePath)) {
+        return {}
+    }
+
+    return {
+        hmr: {host},
+        host,
+        https: {
+            key: fs.readFileSync(keyPath),
+            cert: fs.readFileSync(certificatePath),
+        },
+        watch: {
+            usePolling: true,
+        }
+    }
+}