litestar-vite-plugin 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +45 -0
- package/README.md +2 -0
- package/dist/dev-server-index.html +68 -0
- package/dist/index.cjs +366 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.mjs +335 -0
- package/inertia-helpers/index.d.ts +1 -0
- package/inertia-helpers/index.js +7 -0
- package/package.json +64 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021, 2022, 2023 Litestar Org.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
Code adapted from:
|
|
24
|
+
|
|
25
|
+
The MIT License (MIT)
|
|
26
|
+
|
|
27
|
+
Copyright (c) Taylor Otwell
|
|
28
|
+
|
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
30
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
31
|
+
in the Software without restriction, including without limitation the rights
|
|
32
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
33
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
34
|
+
furnished to do so, subject to the following conditions:
|
|
35
|
+
|
|
36
|
+
The above copyright notice and this permission notice shall be included in
|
|
37
|
+
all copies or substantial portions of the Software.
|
|
38
|
+
|
|
39
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
40
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
41
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
42
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
43
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
44
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
45
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
|
|
7
|
+
<title>Litestar Vite</title>
|
|
8
|
+
|
|
9
|
+
<!-- Fonts -->
|
|
10
|
+
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
|
|
11
|
+
|
|
12
|
+
<!-- Styles -->
|
|
13
|
+
<style>
|
|
14
|
+
/* ! tailwindcss v3.1.4 | MIT License | https://tailwindcss.com */*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Nunito,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.fixed{position:fixed}.relative{position:relative}.top-0{top:0px}.right-0{right:0px}.z-0{z-index:0}.mx-auto{margin-left:auto;margin-right:auto}.ml-3{margin-left:.75rem}.-ml-px{margin-left:-1px}.ml-1{margin-left:.25rem}.mt-2{margin-top:.5rem}.mr-2{margin-right:.5rem}.ml-2{margin-left:.5rem}.mt-4{margin-top:1rem}.ml-4{margin-left:1rem}.mt-8{margin-top:2rem}.ml-12{margin-left:3rem}.-mt-px{margin-top:-1px}.mt-6{margin-top:1.5rem}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-5{height:1.25rem}.h-8{height:2rem}.h-16{height:4rem}.h-6{height:1.5rem}.min-h-screen{min-height:100vh}.w-5{width:1.25rem}.w-8{width:2rem}.w-auto{width:auto}.w-6{width:1.5rem}.max-w-xl{max-width:36rem}.max-w-6xl{max-width:72rem}.flex-1{flex:1 1 0%}.cursor-default{cursor:default}.resize{resize:both}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.justify-items-center{justify-items:center}.space-x-6>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1.5rem * var(--tw-space-x-reverse));margin-left:calc(1.5rem * calc(1 - var(--tw-space-x-reverse)))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-gray-300>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(209 213 219 / var(--tw-divide-opacity))}.overflow-hidden{overflow:hidden}.rounded-md{border-radius:.375rem}.rounded-lg{border-radius:.5rem}.rounded-l-md{border-top-left-radius:.375rem;border-bottom-left-radius:.375rem}.rounded-r-md{border-top-right-radius:.375rem;border-bottom-right-radius:.375rem}.border{border-width:1px}.border-t{border-top-width:1px}.border-r{border-right-width:1px}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity))}.border-gray-400{--tw-border-opacity: 1;border-color:rgb(156 163 175 / var(--tw-border-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity))}.p-6{padding:1.5rem}.px-4{padding-left:1rem;padding-right:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.py-4{padding-top:1rem;padding-bottom:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pt-8{padding-top:2rem}.pt-10{padding-top:2.5rem}.pb-8{padding-bottom:2rem}.text-center{text-align:center}.text-sm{font-size:.875rem;line-height:1.25rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-base{font-size:1rem;line-height:1.5rem}.font-medium{font-weight:500}.font-semibold{font-weight:600}.font-bold{font-weight:700}.uppercase{text-transform:uppercase}.leading-5{line-height:1.25rem}.leading-7{line-height:1.75rem}.tracking-wider{letter-spacing:.05em}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.text-gray-200{--tw-text-opacity: 1;color:rgb(229 231 235 / var(--tw-text-opacity))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity))}.underline{text-decoration-line:underline}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-gray-300{--tw-ring-opacity: 1;--tw-ring-color: rgb(209 213 219 / var(--tw-ring-opacity))}.ring-gray-900{--tw-ring-opacity: 1;--tw-ring-color: rgb(17 24 39 / var(--tw-ring-opacity))}.ring-gray-900\/5{--tw-ring-color: rgb(17 24 39 / .05)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-150{transition-duration:.15s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.hover\:text-gray-500:hover{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity))}.hover\:text-gray-400:hover{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity))}.focus\:z-10:focus{z-index:10}.focus\:border-blue-300:focus{--tw-border-opacity: 1;border-color:rgb(147 197 253 / var(--tw-border-opacity))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.active\:bg-gray-100:active{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity))}.active\:text-gray-700:active{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.active\:text-gray-500:active{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity))}@media (prefers-color-scheme: dark){.dark\:divide-gray-700>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(55 65 81 / var(--tw-divide-opacity))}.dark\:bg-gray-900{--tw-bg-opacity: 1;background-color:rgb(17 24 39 / var(--tw-bg-opacity))}.dark\:bg-gray-800{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity))}.dark\:text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}.dark\:text-gray-100{--tw-text-opacity: 1;color:rgb(243 244 246 / var(--tw-text-opacity))}}@media (min-width: 640px){.sm\:mx-auto{margin-left:auto;margin-right:auto}.sm\:flex{display:flex}.sm\:hidden{display:none}.sm\:max-w-xl{max-width:36rem}.sm\:flex-1{flex:1 1 0%}.sm\:items-center{align-items:center}.sm\:justify-start{justify-content:flex-start}.sm\:justify-between{justify-content:space-between}.sm\:rounded-lg{border-radius:.5rem}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}.sm\:py-12{padding-top:3rem;padding-bottom:3rem}.sm\:px-10{padding-left:2.5rem;padding-right:2.5rem}.sm\:pt-0{padding-top:0}}@media (min-width: 1024px){.lg\:px-8{padding-left:2rem;padding-right:2rem}}
|
|
15
|
+
</style>
|
|
16
|
+
</head>
|
|
17
|
+
<body class="antialiased">
|
|
18
|
+
<div class="relative flex min-h-screen flex-col justify-center overflow-hidden bg-gray-100 text-gray-600 dark:text-gray-400 dark:bg-gray-900 py-6 sm:py-12">
|
|
19
|
+
<div class="relative bg-white dark:bg-gray-800 px-6 pt-10 pb-8 shadow-xl ring-1 ring-gray-900/5 sm:mx-auto sm:max-w-xl sm:rounded-lg sm:px-10">
|
|
20
|
+
<div class="mx-auto">
|
|
21
|
+
<div class="flex items-center justify-center space-x-6">
|
|
22
|
+
<a href="https://litestar.dev">
|
|
23
|
+
<svg viewBox="0 0 316 316" xmlns="http://www.w3.org/2000/svg" class="h-16 w-auto">
|
|
24
|
+
<path fill="#EF3B2D" d="M305.8 81.125C305.77 80.995 305.69 80.885 305.65 80.755C305.56 80.525 305.49 80.285 305.37 80.075C305.29 79.935 305.17 79.815 305.07 79.685C304.94 79.515 304.83 79.325 304.68 79.175C304.55 79.045 304.39 78.955 304.25 78.845C304.09 78.715 303.95 78.575 303.77 78.475L251.32 48.275C249.97 47.495 248.31 47.495 246.96 48.275L194.51 78.475C194.33 78.575 194.19 78.725 194.03 78.845C193.89 78.955 193.73 79.045 193.6 79.175C193.45 79.325 193.34 79.515 193.21 79.685C193.11 79.815 192.99 79.935 192.91 80.075C192.79 80.285 192.71 80.525 192.63 80.755C192.58 80.875 192.51 80.995 192.48 81.125C192.38 81.495 192.33 81.875 192.33 82.265V139.625L148.62 164.795V52.575C148.62 52.185 148.57 51.805 148.47 51.435C148.44 51.305 148.36 51.195 148.32 51.065C148.23 50.835 148.16 50.595 148.04 50.385C147.96 50.245 147.84 50.125 147.74 49.995C147.61 49.825 147.5 49.635 147.35 49.485C147.22 49.355 147.06 49.265 146.92 49.155C146.76 49.025 146.62 48.885 146.44 48.785L93.99 18.585C92.64 17.805 90.98 17.805 89.63 18.585L37.18 48.785C37 48.885 36.86 49.035 36.7 49.155C36.56 49.265 36.4 49.355 36.27 49.485C36.12 49.635 36.01 49.825 35.88 49.995C35.78 50.125 35.66 50.245 35.58 50.385C35.46 50.595 35.38 50.835 35.3 51.065C35.25 51.185 35.18 51.305 35.15 51.435C35.05 51.805 35 52.185 35 52.575V232.235C35 233.795 35.84 235.245 37.19 236.025L142.1 296.425C142.33 296.555 142.58 296.635 142.82 296.725C142.93 296.765 143.04 296.835 143.16 296.865C143.53 296.965 143.9 297.015 144.28 297.015C144.66 297.015 145.03 296.965 145.4 296.865C145.5 296.835 145.59 296.775 145.69 296.745C145.95 296.655 146.21 296.565 146.45 296.435L251.36 236.035C252.72 235.255 253.55 233.815 253.55 232.245V174.885L303.81 145.945C305.17 145.165 306 143.725 306 142.155V82.265C305.95 81.875 305.89 81.495 305.8 81.125ZM144.2 227.205L100.57 202.515L146.39 176.135L196.66 147.195L240.33 172.335L208.29 190.625L144.2 227.205ZM244.75 114.995V164.795L226.39 154.225L201.03 139.625V89.825L219.39 100.395L244.75 114.995ZM249.12 57.105L292.81 82.265L249.12 107.425L205.43 82.265L249.12 57.105ZM114.49 184.425L96.13 194.995V85.305L121.49 70.705L139.85 60.135V169.815L114.49 184.425ZM91.76 27.425L135.45 52.585L91.76 77.745L48.07 52.585L91.76 27.425ZM43.67 60.135L62.03 70.705L87.39 85.305V202.545V202.555V202.565C87.39 202.735 87.44 202.895 87.46 203.055C87.49 203.265 87.49 203.485 87.55 203.695V203.705C87.6 203.875 87.69 204.035 87.76 204.195C87.84 204.375 87.89 204.575 87.99 204.745C87.99 204.745 87.99 204.755 88 204.755C88.09 204.905 88.22 205.035 88.33 205.175C88.45 205.335 88.55 205.495 88.69 205.635L88.7 205.645C88.82 205.765 88.98 205.855 89.12 205.965C89.28 206.085 89.42 206.225 89.59 206.325C89.6 206.325 89.6 206.325 89.61 206.335C89.62 206.335 89.62 206.345 89.63 206.345L139.87 234.775V285.065L43.67 229.705V60.135ZM244.75 229.705L148.58 285.075V234.775L219.8 194.115L244.75 179.875V229.705ZM297.2 139.625L253.49 164.795V114.995L278.85 100.395L297.21 89.825V139.625H297.2Z" />
|
|
25
|
+
</svg>
|
|
26
|
+
</a>
|
|
27
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
28
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4v16m8-8H4" />
|
|
29
|
+
</svg>
|
|
30
|
+
<a href="https://vitejs.dev">
|
|
31
|
+
<svg viewBox="0 0 410 404" fill="none" xmlns="http://www.w3.org/2000/svg" class="h-16 w-auto">
|
|
32
|
+
<path d="M399.641 59.5246L215.643 388.545C211.844 395.338 202.084 395.378 198.228 388.618L10.5817 59.5563C6.38087 52.1896 12.6802 43.2665 21.0281 44.7586L205.223 77.6824C206.398 77.8924 207.601 77.8904 208.776 77.6763L389.119 44.8058C397.439 43.2894 403.768 52.1434 399.641 59.5246Z" fill="url(#paint0_linear)" />
|
|
33
|
+
<path d="M292.965 1.5744L156.801 28.2552C154.563 28.6937 152.906 30.5903 152.771 32.8664L144.395 174.33C144.198 177.662 147.258 180.248 150.51 179.498L188.42 170.749C191.967 169.931 195.172 173.055 194.443 176.622L183.18 231.775C182.422 235.487 185.907 238.661 189.532 237.56L212.947 230.446C216.577 229.344 220.065 232.527 219.297 236.242L201.398 322.875C200.278 328.294 207.486 331.249 210.492 326.603L212.5 323.5L323.454 102.072C325.312 98.3645 322.108 94.137 318.036 94.9228L279.014 102.454C275.347 103.161 272.227 99.746 273.262 96.1583L298.731 7.86689C299.767 4.27314 296.636 0.855181 292.965 1.5744Z" fill="url(#paint1_linear)" />
|
|
34
|
+
<defs>
|
|
35
|
+
<linearGradient id="paint0_linear" x1="6.00017" y1="32.9999" x2="235" y2="344" gradientUnits="userSpaceOnUse">
|
|
36
|
+
<stop stop-color="#41D1FF" />
|
|
37
|
+
<stop offset="1" stop-color="#BD34FE" />
|
|
38
|
+
</linearGradient>
|
|
39
|
+
<linearGradient id="paint1_linear" x1="194.651" y1="8.81818" x2="236.076" y2="292.989" gradientUnits="userSpaceOnUse">
|
|
40
|
+
<stop stop-color="#FFEA83" />
|
|
41
|
+
<stop offset="0.0833333" stop-color="#FFDD35" />
|
|
42
|
+
<stop offset="1" stop-color="#FFA800" />
|
|
43
|
+
</linearGradient>
|
|
44
|
+
</defs>
|
|
45
|
+
</svg>
|
|
46
|
+
</a>
|
|
47
|
+
</div>
|
|
48
|
+
<div class="divide-y divide-gray-300 dark:divide-gray-700">
|
|
49
|
+
<div class="py-8 text-base leading-7">
|
|
50
|
+
<p>This is the Vite development server that provides Hot Module Replacement for your Litestar application.</p>
|
|
51
|
+
<p class="mt-6">To access your Litestar application, you will need to run a local development server.</p>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="pt-8 text-base leading-7">
|
|
54
|
+
<p>
|
|
55
|
+
Your Litestar application's configured <code class="text-sm font-bold text-gray-900 dark:text-gray-100">APP_URL</code> is:<br />
|
|
56
|
+
<a href="{{ APP_URL }}" class="font-semibold text-red-500 hover:text-red-600">{{ APP_URL }}</a>
|
|
57
|
+
</p>
|
|
58
|
+
<p class="mt-6">Want more information on Litestar's Vite integration?</p>
|
|
59
|
+
<p>
|
|
60
|
+
<a href="https://litestar.dev/docs/vite" class="font-semibold text-red-500 hover:text-red-600">Read the docs →</a>
|
|
61
|
+
</p>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</body>
|
|
68
|
+
</html>
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var src_exports = {};
|
|
26
|
+
__export(src_exports, {
|
|
27
|
+
default: () => litestar,
|
|
28
|
+
refreshPaths: () => refreshPaths
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(src_exports);
|
|
31
|
+
var import_meta_url = typeof document === "undefined" ? new (require("url".replace("", ""))).URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
32
|
+
var import_fs = __toESM(require("fs"));
|
|
33
|
+
var import_url = require("url");
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_picocolors = __toESM(require("picocolors"));
|
|
36
|
+
var import_vite = require("vite");
|
|
37
|
+
var import_vite_plugin_full_reload = __toESM(require("vite-plugin-full-reload"));
|
|
38
|
+
let exitHandlersBound = false;
|
|
39
|
+
const refreshPaths = [
|
|
40
|
+
"app/View/Components/**",
|
|
41
|
+
"resources/views/**",
|
|
42
|
+
"resources/lang/**",
|
|
43
|
+
"lang/**",
|
|
44
|
+
"routes/**"
|
|
45
|
+
];
|
|
46
|
+
function litestar(config) {
|
|
47
|
+
const pluginConfig = resolvePluginConfig(config);
|
|
48
|
+
return [
|
|
49
|
+
resolveLitestarPlugin(pluginConfig),
|
|
50
|
+
...resolveFullReloadConfig(pluginConfig)
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
function resolveLitestarPlugin(pluginConfig) {
|
|
54
|
+
let viteDevServerUrl;
|
|
55
|
+
let resolvedConfig;
|
|
56
|
+
let userConfig;
|
|
57
|
+
const defaultAliases = {
|
|
58
|
+
"@": "/resources/js"
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
name: "litestar",
|
|
62
|
+
enforce: "post",
|
|
63
|
+
config: (config, { command, mode }) => {
|
|
64
|
+
userConfig = config;
|
|
65
|
+
const ssr = !!userConfig.build?.ssr;
|
|
66
|
+
const env = (0, import_vite.loadEnv)(mode, userConfig.envDir || process.cwd(), "");
|
|
67
|
+
const assetUrl = env.ASSET_URL ?? "";
|
|
68
|
+
const serverConfig = command === "serve" ? resolveDevelopmentEnvironmentServerConfig(pluginConfig.detectTls) ?? resolveEnvironmentServerConfig(env) : void 0;
|
|
69
|
+
ensureCommandShouldRunInEnvironment(command, env);
|
|
70
|
+
return {
|
|
71
|
+
base: userConfig.base ?? (command === "build" ? resolveBase(pluginConfig, assetUrl) : ""),
|
|
72
|
+
publicDir: userConfig.publicDir ?? false,
|
|
73
|
+
build: {
|
|
74
|
+
manifest: userConfig.build?.manifest ?? !ssr,
|
|
75
|
+
outDir: userConfig.build?.outDir ?? resolveOutDir(pluginConfig, ssr),
|
|
76
|
+
rollupOptions: {
|
|
77
|
+
input: userConfig.build?.rollupOptions?.input ?? resolveInput(pluginConfig, ssr)
|
|
78
|
+
},
|
|
79
|
+
assetsInlineLimit: userConfig.build?.assetsInlineLimit ?? 0
|
|
80
|
+
},
|
|
81
|
+
server: {
|
|
82
|
+
origin: userConfig.server?.origin ?? "__litestar_vite_placeholder__",
|
|
83
|
+
...process.env.LITESTAR_VITE_IN_CONTAINER ? {
|
|
84
|
+
host: userConfig.server?.host ?? "0.0.0.0",
|
|
85
|
+
port: userConfig.server?.port ?? (env.VITE_PORT ? parseInt(env.VITE_PORT) : 5173),
|
|
86
|
+
strictPort: userConfig.server?.strictPort ?? true
|
|
87
|
+
} : void 0,
|
|
88
|
+
...serverConfig ? {
|
|
89
|
+
host: userConfig.server?.host ?? serverConfig.host,
|
|
90
|
+
hmr: userConfig.server?.hmr === false ? false : {
|
|
91
|
+
...serverConfig.hmr,
|
|
92
|
+
...userConfig.server?.hmr === true ? {} : userConfig.server?.hmr
|
|
93
|
+
},
|
|
94
|
+
https: userConfig.server?.https === false ? false : {
|
|
95
|
+
...serverConfig.https,
|
|
96
|
+
...userConfig.server?.https === true ? {} : userConfig.server?.https
|
|
97
|
+
}
|
|
98
|
+
} : void 0
|
|
99
|
+
},
|
|
100
|
+
resolve: {
|
|
101
|
+
alias: Array.isArray(userConfig.resolve?.alias) ? [
|
|
102
|
+
...userConfig.resolve?.alias ?? [],
|
|
103
|
+
...Object.keys(defaultAliases).map((alias) => ({
|
|
104
|
+
find: alias,
|
|
105
|
+
replacement: defaultAliases[alias]
|
|
106
|
+
}))
|
|
107
|
+
] : {
|
|
108
|
+
...defaultAliases,
|
|
109
|
+
...userConfig.resolve?.alias
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
ssr: {
|
|
113
|
+
noExternal: noExternalInertiaHelpers(userConfig)
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
configResolved(config) {
|
|
118
|
+
resolvedConfig = config;
|
|
119
|
+
},
|
|
120
|
+
transform(code) {
|
|
121
|
+
if (resolvedConfig.command === "serve") {
|
|
122
|
+
code = code.replace(/__litestar_vite_placeholder__/g, viteDevServerUrl);
|
|
123
|
+
return pluginConfig.transformOnServe(code, viteDevServerUrl);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
configureServer(server) {
|
|
127
|
+
const envDir = resolvedConfig.envDir || process.cwd();
|
|
128
|
+
const appUrl = (0, import_vite.loadEnv)(resolvedConfig.mode, envDir, "APP_URL").APP_URL ?? "undefined";
|
|
129
|
+
server.httpServer?.once("listening", () => {
|
|
130
|
+
const address = server.httpServer?.address();
|
|
131
|
+
const isAddressInfo = (x) => typeof x === "object";
|
|
132
|
+
if (isAddressInfo(address)) {
|
|
133
|
+
viteDevServerUrl = resolveDevServerUrl(address, server.config, userConfig);
|
|
134
|
+
import_fs.default.writeFileSync(pluginConfig.hotFile, viteDevServerUrl);
|
|
135
|
+
setTimeout(() => {
|
|
136
|
+
server.config.logger.info(`
|
|
137
|
+
${import_picocolors.default.red(`${import_picocolors.default.bold("LITESTAR")} ${litestarVersion()}`)} ${import_picocolors.default.dim("plugin")} ${import_picocolors.default.bold(`v${pluginVersion()}`)}`);
|
|
138
|
+
server.config.logger.info("");
|
|
139
|
+
server.config.logger.info(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("APP_URL")}: ${import_picocolors.default.cyan(appUrl.replace(/:(\d+)/, (_, port) => `:${import_picocolors.default.bold(port)}`))}`);
|
|
140
|
+
}, 100);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
if (!exitHandlersBound) {
|
|
144
|
+
const clean = () => {
|
|
145
|
+
if (import_fs.default.existsSync(pluginConfig.hotFile)) {
|
|
146
|
+
import_fs.default.rmSync(pluginConfig.hotFile);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
process.on("exit", clean);
|
|
150
|
+
process.on("SIGINT", process.exit);
|
|
151
|
+
process.on("SIGTERM", process.exit);
|
|
152
|
+
process.on("SIGHUP", process.exit);
|
|
153
|
+
exitHandlersBound = true;
|
|
154
|
+
}
|
|
155
|
+
return () => server.middlewares.use((req, res, next) => {
|
|
156
|
+
if (req.url === "/index.html") {
|
|
157
|
+
res.statusCode = 404;
|
|
158
|
+
res.end(
|
|
159
|
+
import_fs.default.readFileSync(import_path.default.join(dirname(), "dev-server-index.html")).toString().replace(/{{ APP_URL }}/g, appUrl)
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
next();
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function ensureCommandShouldRunInEnvironment(command, env) {
|
|
168
|
+
if (command === "build" || env.LITESTAR_BYPASS_ENV_CHECK === "1") {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (typeof env.LITESTAR_MODE !== "undefined") {
|
|
172
|
+
throw Error("You should not run the Vite HMR server when Litestar is in production. You should build your assets for production instead. To disable this ENV check you may set LITESTAR_BYPASS_ENV_CHECK=1");
|
|
173
|
+
}
|
|
174
|
+
if (typeof env.CI !== "undefined") {
|
|
175
|
+
throw Error("You should not run the Vite HMR server in CI environments. You should build your assets for production instead. To disable this ENV check you may set LITESTAR_BYPASS_ENV_CHECK=1");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function litestarVersion() {
|
|
179
|
+
try {
|
|
180
|
+
const composer = JSON.parse(import_fs.default.readFileSync("composer.lock").toString());
|
|
181
|
+
return composer.packages?.find((composerPackage) => composerPackage.name === "litestar/framework")?.version ?? "";
|
|
182
|
+
} catch {
|
|
183
|
+
return "";
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function pluginVersion() {
|
|
187
|
+
try {
|
|
188
|
+
return JSON.parse(import_fs.default.readFileSync(import_path.default.join(dirname(), "../package.json")).toString())?.version;
|
|
189
|
+
} catch {
|
|
190
|
+
return "";
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function resolvePluginConfig(config) {
|
|
194
|
+
if (typeof config === "undefined") {
|
|
195
|
+
throw new Error("litestar-vite-plugin: missing configuration.");
|
|
196
|
+
}
|
|
197
|
+
if (typeof config === "string" || Array.isArray(config)) {
|
|
198
|
+
config = { input: config, ssr: config };
|
|
199
|
+
}
|
|
200
|
+
if (typeof config.input === "undefined") {
|
|
201
|
+
throw new Error('litestar-vite-plugin: missing configuration for "input".');
|
|
202
|
+
}
|
|
203
|
+
if (typeof config.publicDirectory === "string") {
|
|
204
|
+
config.publicDirectory = config.publicDirectory.trim().replace(/^\/+/, "");
|
|
205
|
+
if (config.publicDirectory === "") {
|
|
206
|
+
throw new Error("litestar-vite-plugin: publicDirectory must be a subdirectory. E.g. 'public'.");
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (typeof config.buildDirectory === "string") {
|
|
210
|
+
config.buildDirectory = config.buildDirectory.trim().replace(/^\/+/, "").replace(/\/+$/, "");
|
|
211
|
+
if (config.buildDirectory === "") {
|
|
212
|
+
throw new Error("litestar-vite-plugin: buildDirectory must be a subdirectory. E.g. 'build'.");
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (typeof config.ssrOutputDirectory === "string") {
|
|
216
|
+
config.ssrOutputDirectory = config.ssrOutputDirectory.trim().replace(/^\/+/, "").replace(/\/+$/, "");
|
|
217
|
+
}
|
|
218
|
+
if (config.refresh === true) {
|
|
219
|
+
config.refresh = [{ paths: refreshPaths }];
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
input: config.input,
|
|
223
|
+
publicDirectory: config.publicDirectory ?? "public",
|
|
224
|
+
buildDirectory: config.buildDirectory ?? "build",
|
|
225
|
+
ssr: config.ssr ?? config.input,
|
|
226
|
+
ssrOutputDirectory: config.ssrOutputDirectory ?? "bootstrap/ssr",
|
|
227
|
+
refresh: config.refresh ?? false,
|
|
228
|
+
hotFile: config.hotFile ?? import_path.default.join(config.publicDirectory ?? "public", "hot"),
|
|
229
|
+
detectTls: config.detectTls ?? false,
|
|
230
|
+
transformOnServe: config.transformOnServe ?? ((code) => code)
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function resolveBase(config, assetUrl) {
|
|
234
|
+
return assetUrl + (assetUrl.endsWith("/") ? "" : "/") + config.buildDirectory + "/";
|
|
235
|
+
}
|
|
236
|
+
function resolveInput(config, ssr) {
|
|
237
|
+
if (ssr) {
|
|
238
|
+
return config.ssr;
|
|
239
|
+
}
|
|
240
|
+
return config.input;
|
|
241
|
+
}
|
|
242
|
+
function resolveOutDir(config, ssr) {
|
|
243
|
+
if (ssr) {
|
|
244
|
+
return config.ssrOutputDirectory;
|
|
245
|
+
}
|
|
246
|
+
return import_path.default.join(config.publicDirectory, config.buildDirectory);
|
|
247
|
+
}
|
|
248
|
+
function resolveFullReloadConfig({ refresh: config }) {
|
|
249
|
+
if (typeof config === "boolean") {
|
|
250
|
+
return [];
|
|
251
|
+
}
|
|
252
|
+
if (typeof config === "string") {
|
|
253
|
+
config = [{ paths: [config] }];
|
|
254
|
+
}
|
|
255
|
+
if (!Array.isArray(config)) {
|
|
256
|
+
config = [config];
|
|
257
|
+
}
|
|
258
|
+
if (config.some((c) => typeof c === "string")) {
|
|
259
|
+
config = [{ paths: config }];
|
|
260
|
+
}
|
|
261
|
+
return config.flatMap((c) => {
|
|
262
|
+
const plugin = (0, import_vite_plugin_full_reload.default)(c.paths, c.config);
|
|
263
|
+
plugin.__litestar_plugin_config = c;
|
|
264
|
+
return plugin;
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function resolveDevServerUrl(address, config, userConfig) {
|
|
268
|
+
const configHmrProtocol = typeof config.server.hmr === "object" ? config.server.hmr.protocol : null;
|
|
269
|
+
const clientProtocol = configHmrProtocol ? configHmrProtocol === "wss" ? "https" : "http" : null;
|
|
270
|
+
const serverProtocol = config.server.https ? "https" : "http";
|
|
271
|
+
const protocol = clientProtocol ?? serverProtocol;
|
|
272
|
+
const configHmrHost = typeof config.server.hmr === "object" ? config.server.hmr.host : null;
|
|
273
|
+
const configHost = typeof config.server.host === "string" ? config.server.host : null;
|
|
274
|
+
const remoteHost = process.env.LITESTAR_VITE_IN_CONTAINER && !userConfig.server?.host ? "localhost" : null;
|
|
275
|
+
const serverAddress = isIpv6(address) ? `[${address.address}]` : address.address;
|
|
276
|
+
const host = configHmrHost ?? remoteHost ?? configHost ?? serverAddress;
|
|
277
|
+
const configHmrClientPort = typeof config.server.hmr === "object" ? config.server.hmr.clientPort : null;
|
|
278
|
+
const port = configHmrClientPort ?? address.port;
|
|
279
|
+
return `${protocol}://${host}:${port}`;
|
|
280
|
+
}
|
|
281
|
+
function isIpv6(address) {
|
|
282
|
+
return address.family === "IPv6" || address.family === 6;
|
|
283
|
+
}
|
|
284
|
+
function noExternalInertiaHelpers(config) {
|
|
285
|
+
const userNoExternal = config.ssr?.noExternal;
|
|
286
|
+
const pluginNoExternal = ["litestar-vite-plugin"];
|
|
287
|
+
if (userNoExternal === true) {
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
if (typeof userNoExternal === "undefined") {
|
|
291
|
+
return pluginNoExternal;
|
|
292
|
+
}
|
|
293
|
+
return [
|
|
294
|
+
...Array.isArray(userNoExternal) ? userNoExternal : [userNoExternal],
|
|
295
|
+
...pluginNoExternal
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
function resolveEnvironmentServerConfig(env) {
|
|
299
|
+
if (!env.VITE_DEV_SERVER_KEY && !env.VITE_DEV_SERVER_CERT) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (!import_fs.default.existsSync(env.VITE_DEV_SERVER_KEY) || !import_fs.default.existsSync(env.VITE_DEV_SERVER_CERT)) {
|
|
303
|
+
throw Error(`Unable to find the certificate files specified in your environment. Ensure you have correctly configured VITE_DEV_SERVER_KEY: [${env.VITE_DEV_SERVER_KEY}] and VITE_DEV_SERVER_CERT: [${env.VITE_DEV_SERVER_CERT}].`);
|
|
304
|
+
}
|
|
305
|
+
const host = resolveHostFromEnv(env);
|
|
306
|
+
if (!host) {
|
|
307
|
+
throw Error(`Unable to determine the host from the environment's APP_URL: [${env.APP_URL}].`);
|
|
308
|
+
}
|
|
309
|
+
return {
|
|
310
|
+
hmr: { host },
|
|
311
|
+
host,
|
|
312
|
+
https: {
|
|
313
|
+
key: import_fs.default.readFileSync(env.VITE_DEV_SERVER_KEY),
|
|
314
|
+
cert: import_fs.default.readFileSync(env.VITE_DEV_SERVER_CERT)
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function resolveHostFromEnv(env) {
|
|
319
|
+
try {
|
|
320
|
+
return new URL(env.APP_URL).host;
|
|
321
|
+
} catch {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function resolveDevelopmentEnvironmentServerConfig(host) {
|
|
326
|
+
if (host === false) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
const configPath = determineDevelopmentEnvironmentConfigPath();
|
|
330
|
+
host = host === true ? resolveDevelopmentEnvironmentHost(configPath) : host;
|
|
331
|
+
const keyPath = import_path.default.resolve(configPath, "certs", `${host}.key`);
|
|
332
|
+
const certPath = import_path.default.resolve(configPath, "certs", `${host}.crt`);
|
|
333
|
+
if (!import_fs.default.existsSync(keyPath) || !import_fs.default.existsSync(certPath)) {
|
|
334
|
+
throw Error(`Unable to find certificate files for your host [${host}] in the [${configPath}/certs] directory.`);
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
hmr: { host },
|
|
338
|
+
host,
|
|
339
|
+
https: {
|
|
340
|
+
key: import_fs.default.readFileSync(keyPath),
|
|
341
|
+
cert: import_fs.default.readFileSync(certPath)
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function determineDevelopmentEnvironmentConfigPath() {
|
|
346
|
+
const envConfigPath = import_path.default.resolve(process.cwd(), ".config");
|
|
347
|
+
if (import_fs.default.existsSync(envConfigPath)) {
|
|
348
|
+
return envConfigPath;
|
|
349
|
+
}
|
|
350
|
+
return import_path.default.resolve(process.cwd(), ".config");
|
|
351
|
+
}
|
|
352
|
+
function resolveDevelopmentEnvironmentHost(configPath) {
|
|
353
|
+
const configFile = import_path.default.resolve(configPath, "config.json");
|
|
354
|
+
if (!import_fs.default.existsSync(configFile)) {
|
|
355
|
+
throw Error(`Unable to find the configuration file [${configFile}]. You will need to manually specify the host in the \`detectTls\` configuration option.`);
|
|
356
|
+
}
|
|
357
|
+
const config = JSON.parse(import_fs.default.readFileSync(configFile, "utf-8"));
|
|
358
|
+
return import_path.default.basename(process.cwd()) + "." + config.tld;
|
|
359
|
+
}
|
|
360
|
+
function dirname() {
|
|
361
|
+
return (0, import_url.fileURLToPath)(new URL(".", import_meta_url));
|
|
362
|
+
}
|
|
363
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
364
|
+
0 && (module.exports = {
|
|
365
|
+
refreshPaths
|
|
366
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Plugin, UserConfig, ConfigEnv } from 'vite';
|
|
2
|
+
import { Config as FullReloadConfig } from 'vite-plugin-full-reload';
|
|
3
|
+
interface PluginConfig {
|
|
4
|
+
/**
|
|
5
|
+
* The path or paths of the entry points to compile.
|
|
6
|
+
*/
|
|
7
|
+
input: string | string[];
|
|
8
|
+
/**
|
|
9
|
+
* Litestar's public directory.
|
|
10
|
+
*
|
|
11
|
+
* @default 'public'
|
|
12
|
+
*/
|
|
13
|
+
publicDirectory?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The public subdirectory where compiled assets should be written.
|
|
16
|
+
*
|
|
17
|
+
* @default 'build'
|
|
18
|
+
*/
|
|
19
|
+
buildDirectory?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The path to the "hot" file.
|
|
22
|
+
*
|
|
23
|
+
* @default `${publicDirectory}/hot`
|
|
24
|
+
*/
|
|
25
|
+
hotFile?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The path of the SSR entry point.
|
|
28
|
+
*/
|
|
29
|
+
ssr?: string | string[];
|
|
30
|
+
/**
|
|
31
|
+
* The directory where the SSR bundle should be written.
|
|
32
|
+
*
|
|
33
|
+
* @default 'bootstrap/ssr'
|
|
34
|
+
*/
|
|
35
|
+
ssrOutputDirectory?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Configuration for performing full page refresh on blade (or other) file changes.
|
|
38
|
+
*
|
|
39
|
+
* {@link https://github.com/ElMassimo/vite-plugin-full-reload}
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
refresh?: boolean | string | string[] | RefreshConfig | RefreshConfig[];
|
|
43
|
+
/**
|
|
44
|
+
* Utilize TLS certificates.
|
|
45
|
+
*
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
detectTls?: string | boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Transform the code while serving.
|
|
51
|
+
*/
|
|
52
|
+
transformOnServe?: (code: string, url: DevServerUrl) => string;
|
|
53
|
+
}
|
|
54
|
+
interface RefreshConfig {
|
|
55
|
+
paths: string[];
|
|
56
|
+
config?: FullReloadConfig;
|
|
57
|
+
}
|
|
58
|
+
interface LitestarPlugin extends Plugin {
|
|
59
|
+
config: (config: UserConfig, env: ConfigEnv) => UserConfig;
|
|
60
|
+
}
|
|
61
|
+
type DevServerUrl = `${'http' | 'https'}://${string}:${number}`;
|
|
62
|
+
export declare const refreshPaths: string[];
|
|
63
|
+
/**
|
|
64
|
+
* Litestar plugin for Vite.
|
|
65
|
+
*
|
|
66
|
+
* @param config - A config object or relative path(s) of the scripts to be compiled.
|
|
67
|
+
*/
|
|
68
|
+
export default function litestar(config: string | string[] | PluginConfig): [LitestarPlugin, ...Plugin[]];
|
|
69
|
+
export {};
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import colors from "picocolors";
|
|
5
|
+
import { loadEnv } from "vite";
|
|
6
|
+
import fullReload from "vite-plugin-full-reload";
|
|
7
|
+
let exitHandlersBound = false;
|
|
8
|
+
const refreshPaths = [
|
|
9
|
+
"app/View/Components/**",
|
|
10
|
+
"resources/views/**",
|
|
11
|
+
"resources/lang/**",
|
|
12
|
+
"lang/**",
|
|
13
|
+
"routes/**"
|
|
14
|
+
];
|
|
15
|
+
function litestar(config) {
|
|
16
|
+
const pluginConfig = resolvePluginConfig(config);
|
|
17
|
+
return [
|
|
18
|
+
resolveLitestarPlugin(pluginConfig),
|
|
19
|
+
...resolveFullReloadConfig(pluginConfig)
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
function resolveLitestarPlugin(pluginConfig) {
|
|
23
|
+
let viteDevServerUrl;
|
|
24
|
+
let resolvedConfig;
|
|
25
|
+
let userConfig;
|
|
26
|
+
const defaultAliases = {
|
|
27
|
+
"@": "/resources/js"
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
name: "litestar",
|
|
31
|
+
enforce: "post",
|
|
32
|
+
config: (config, { command, mode }) => {
|
|
33
|
+
userConfig = config;
|
|
34
|
+
const ssr = !!userConfig.build?.ssr;
|
|
35
|
+
const env = loadEnv(mode, userConfig.envDir || process.cwd(), "");
|
|
36
|
+
const assetUrl = env.ASSET_URL ?? "";
|
|
37
|
+
const serverConfig = command === "serve" ? resolveDevelopmentEnvironmentServerConfig(pluginConfig.detectTls) ?? resolveEnvironmentServerConfig(env) : void 0;
|
|
38
|
+
ensureCommandShouldRunInEnvironment(command, env);
|
|
39
|
+
return {
|
|
40
|
+
base: userConfig.base ?? (command === "build" ? resolveBase(pluginConfig, assetUrl) : ""),
|
|
41
|
+
publicDir: userConfig.publicDir ?? false,
|
|
42
|
+
build: {
|
|
43
|
+
manifest: userConfig.build?.manifest ?? !ssr,
|
|
44
|
+
outDir: userConfig.build?.outDir ?? resolveOutDir(pluginConfig, ssr),
|
|
45
|
+
rollupOptions: {
|
|
46
|
+
input: userConfig.build?.rollupOptions?.input ?? resolveInput(pluginConfig, ssr)
|
|
47
|
+
},
|
|
48
|
+
assetsInlineLimit: userConfig.build?.assetsInlineLimit ?? 0
|
|
49
|
+
},
|
|
50
|
+
server: {
|
|
51
|
+
origin: userConfig.server?.origin ?? "__litestar_vite_placeholder__",
|
|
52
|
+
...process.env.LITESTAR_VITE_IN_CONTAINER ? {
|
|
53
|
+
host: userConfig.server?.host ?? "0.0.0.0",
|
|
54
|
+
port: userConfig.server?.port ?? (env.VITE_PORT ? parseInt(env.VITE_PORT) : 5173),
|
|
55
|
+
strictPort: userConfig.server?.strictPort ?? true
|
|
56
|
+
} : void 0,
|
|
57
|
+
...serverConfig ? {
|
|
58
|
+
host: userConfig.server?.host ?? serverConfig.host,
|
|
59
|
+
hmr: userConfig.server?.hmr === false ? false : {
|
|
60
|
+
...serverConfig.hmr,
|
|
61
|
+
...userConfig.server?.hmr === true ? {} : userConfig.server?.hmr
|
|
62
|
+
},
|
|
63
|
+
https: userConfig.server?.https === false ? false : {
|
|
64
|
+
...serverConfig.https,
|
|
65
|
+
...userConfig.server?.https === true ? {} : userConfig.server?.https
|
|
66
|
+
}
|
|
67
|
+
} : void 0
|
|
68
|
+
},
|
|
69
|
+
resolve: {
|
|
70
|
+
alias: Array.isArray(userConfig.resolve?.alias) ? [
|
|
71
|
+
...userConfig.resolve?.alias ?? [],
|
|
72
|
+
...Object.keys(defaultAliases).map((alias) => ({
|
|
73
|
+
find: alias,
|
|
74
|
+
replacement: defaultAliases[alias]
|
|
75
|
+
}))
|
|
76
|
+
] : {
|
|
77
|
+
...defaultAliases,
|
|
78
|
+
...userConfig.resolve?.alias
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
ssr: {
|
|
82
|
+
noExternal: noExternalInertiaHelpers(userConfig)
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
configResolved(config) {
|
|
87
|
+
resolvedConfig = config;
|
|
88
|
+
},
|
|
89
|
+
transform(code) {
|
|
90
|
+
if (resolvedConfig.command === "serve") {
|
|
91
|
+
code = code.replace(/__litestar_vite_placeholder__/g, viteDevServerUrl);
|
|
92
|
+
return pluginConfig.transformOnServe(code, viteDevServerUrl);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
configureServer(server) {
|
|
96
|
+
const envDir = resolvedConfig.envDir || process.cwd();
|
|
97
|
+
const appUrl = loadEnv(resolvedConfig.mode, envDir, "APP_URL").APP_URL ?? "undefined";
|
|
98
|
+
server.httpServer?.once("listening", () => {
|
|
99
|
+
const address = server.httpServer?.address();
|
|
100
|
+
const isAddressInfo = (x) => typeof x === "object";
|
|
101
|
+
if (isAddressInfo(address)) {
|
|
102
|
+
viteDevServerUrl = resolveDevServerUrl(address, server.config, userConfig);
|
|
103
|
+
fs.writeFileSync(pluginConfig.hotFile, viteDevServerUrl);
|
|
104
|
+
setTimeout(() => {
|
|
105
|
+
server.config.logger.info(`
|
|
106
|
+
${colors.red(`${colors.bold("LITESTAR")} ${litestarVersion()}`)} ${colors.dim("plugin")} ${colors.bold(`v${pluginVersion()}`)}`);
|
|
107
|
+
server.config.logger.info("");
|
|
108
|
+
server.config.logger.info(` ${colors.green("\u279C")} ${colors.bold("APP_URL")}: ${colors.cyan(appUrl.replace(/:(\d+)/, (_, port) => `:${colors.bold(port)}`))}`);
|
|
109
|
+
}, 100);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
if (!exitHandlersBound) {
|
|
113
|
+
const clean = () => {
|
|
114
|
+
if (fs.existsSync(pluginConfig.hotFile)) {
|
|
115
|
+
fs.rmSync(pluginConfig.hotFile);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
process.on("exit", clean);
|
|
119
|
+
process.on("SIGINT", process.exit);
|
|
120
|
+
process.on("SIGTERM", process.exit);
|
|
121
|
+
process.on("SIGHUP", process.exit);
|
|
122
|
+
exitHandlersBound = true;
|
|
123
|
+
}
|
|
124
|
+
return () => server.middlewares.use((req, res, next) => {
|
|
125
|
+
if (req.url === "/index.html") {
|
|
126
|
+
res.statusCode = 404;
|
|
127
|
+
res.end(
|
|
128
|
+
fs.readFileSync(path.join(dirname(), "dev-server-index.html")).toString().replace(/{{ APP_URL }}/g, appUrl)
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
next();
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function ensureCommandShouldRunInEnvironment(command, env) {
|
|
137
|
+
if (command === "build" || env.LITESTAR_BYPASS_ENV_CHECK === "1") {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (typeof env.LITESTAR_MODE !== "undefined") {
|
|
141
|
+
throw Error("You should not run the Vite HMR server when Litestar is in production. You should build your assets for production instead. To disable this ENV check you may set LITESTAR_BYPASS_ENV_CHECK=1");
|
|
142
|
+
}
|
|
143
|
+
if (typeof env.CI !== "undefined") {
|
|
144
|
+
throw Error("You should not run the Vite HMR server in CI environments. You should build your assets for production instead. To disable this ENV check you may set LITESTAR_BYPASS_ENV_CHECK=1");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function litestarVersion() {
|
|
148
|
+
try {
|
|
149
|
+
const composer = JSON.parse(fs.readFileSync("composer.lock").toString());
|
|
150
|
+
return composer.packages?.find((composerPackage) => composerPackage.name === "litestar/framework")?.version ?? "";
|
|
151
|
+
} catch {
|
|
152
|
+
return "";
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function pluginVersion() {
|
|
156
|
+
try {
|
|
157
|
+
return JSON.parse(fs.readFileSync(path.join(dirname(), "../package.json")).toString())?.version;
|
|
158
|
+
} catch {
|
|
159
|
+
return "";
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function resolvePluginConfig(config) {
|
|
163
|
+
if (typeof config === "undefined") {
|
|
164
|
+
throw new Error("litestar-vite-plugin: missing configuration.");
|
|
165
|
+
}
|
|
166
|
+
if (typeof config === "string" || Array.isArray(config)) {
|
|
167
|
+
config = { input: config, ssr: config };
|
|
168
|
+
}
|
|
169
|
+
if (typeof config.input === "undefined") {
|
|
170
|
+
throw new Error('litestar-vite-plugin: missing configuration for "input".');
|
|
171
|
+
}
|
|
172
|
+
if (typeof config.publicDirectory === "string") {
|
|
173
|
+
config.publicDirectory = config.publicDirectory.trim().replace(/^\/+/, "");
|
|
174
|
+
if (config.publicDirectory === "") {
|
|
175
|
+
throw new Error("litestar-vite-plugin: publicDirectory must be a subdirectory. E.g. 'public'.");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (typeof config.buildDirectory === "string") {
|
|
179
|
+
config.buildDirectory = config.buildDirectory.trim().replace(/^\/+/, "").replace(/\/+$/, "");
|
|
180
|
+
if (config.buildDirectory === "") {
|
|
181
|
+
throw new Error("litestar-vite-plugin: buildDirectory must be a subdirectory. E.g. 'build'.");
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (typeof config.ssrOutputDirectory === "string") {
|
|
185
|
+
config.ssrOutputDirectory = config.ssrOutputDirectory.trim().replace(/^\/+/, "").replace(/\/+$/, "");
|
|
186
|
+
}
|
|
187
|
+
if (config.refresh === true) {
|
|
188
|
+
config.refresh = [{ paths: refreshPaths }];
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
input: config.input,
|
|
192
|
+
publicDirectory: config.publicDirectory ?? "public",
|
|
193
|
+
buildDirectory: config.buildDirectory ?? "build",
|
|
194
|
+
ssr: config.ssr ?? config.input,
|
|
195
|
+
ssrOutputDirectory: config.ssrOutputDirectory ?? "bootstrap/ssr",
|
|
196
|
+
refresh: config.refresh ?? false,
|
|
197
|
+
hotFile: config.hotFile ?? path.join(config.publicDirectory ?? "public", "hot"),
|
|
198
|
+
detectTls: config.detectTls ?? false,
|
|
199
|
+
transformOnServe: config.transformOnServe ?? ((code) => code)
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function resolveBase(config, assetUrl) {
|
|
203
|
+
return assetUrl + (assetUrl.endsWith("/") ? "" : "/") + config.buildDirectory + "/";
|
|
204
|
+
}
|
|
205
|
+
function resolveInput(config, ssr) {
|
|
206
|
+
if (ssr) {
|
|
207
|
+
return config.ssr;
|
|
208
|
+
}
|
|
209
|
+
return config.input;
|
|
210
|
+
}
|
|
211
|
+
function resolveOutDir(config, ssr) {
|
|
212
|
+
if (ssr) {
|
|
213
|
+
return config.ssrOutputDirectory;
|
|
214
|
+
}
|
|
215
|
+
return path.join(config.publicDirectory, config.buildDirectory);
|
|
216
|
+
}
|
|
217
|
+
function resolveFullReloadConfig({ refresh: config }) {
|
|
218
|
+
if (typeof config === "boolean") {
|
|
219
|
+
return [];
|
|
220
|
+
}
|
|
221
|
+
if (typeof config === "string") {
|
|
222
|
+
config = [{ paths: [config] }];
|
|
223
|
+
}
|
|
224
|
+
if (!Array.isArray(config)) {
|
|
225
|
+
config = [config];
|
|
226
|
+
}
|
|
227
|
+
if (config.some((c) => typeof c === "string")) {
|
|
228
|
+
config = [{ paths: config }];
|
|
229
|
+
}
|
|
230
|
+
return config.flatMap((c) => {
|
|
231
|
+
const plugin = fullReload(c.paths, c.config);
|
|
232
|
+
plugin.__litestar_plugin_config = c;
|
|
233
|
+
return plugin;
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function resolveDevServerUrl(address, config, userConfig) {
|
|
237
|
+
const configHmrProtocol = typeof config.server.hmr === "object" ? config.server.hmr.protocol : null;
|
|
238
|
+
const clientProtocol = configHmrProtocol ? configHmrProtocol === "wss" ? "https" : "http" : null;
|
|
239
|
+
const serverProtocol = config.server.https ? "https" : "http";
|
|
240
|
+
const protocol = clientProtocol ?? serverProtocol;
|
|
241
|
+
const configHmrHost = typeof config.server.hmr === "object" ? config.server.hmr.host : null;
|
|
242
|
+
const configHost = typeof config.server.host === "string" ? config.server.host : null;
|
|
243
|
+
const remoteHost = process.env.LITESTAR_VITE_IN_CONTAINER && !userConfig.server?.host ? "localhost" : null;
|
|
244
|
+
const serverAddress = isIpv6(address) ? `[${address.address}]` : address.address;
|
|
245
|
+
const host = configHmrHost ?? remoteHost ?? configHost ?? serverAddress;
|
|
246
|
+
const configHmrClientPort = typeof config.server.hmr === "object" ? config.server.hmr.clientPort : null;
|
|
247
|
+
const port = configHmrClientPort ?? address.port;
|
|
248
|
+
return `${protocol}://${host}:${port}`;
|
|
249
|
+
}
|
|
250
|
+
function isIpv6(address) {
|
|
251
|
+
return address.family === "IPv6" || address.family === 6;
|
|
252
|
+
}
|
|
253
|
+
function noExternalInertiaHelpers(config) {
|
|
254
|
+
const userNoExternal = config.ssr?.noExternal;
|
|
255
|
+
const pluginNoExternal = ["litestar-vite-plugin"];
|
|
256
|
+
if (userNoExternal === true) {
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
if (typeof userNoExternal === "undefined") {
|
|
260
|
+
return pluginNoExternal;
|
|
261
|
+
}
|
|
262
|
+
return [
|
|
263
|
+
...Array.isArray(userNoExternal) ? userNoExternal : [userNoExternal],
|
|
264
|
+
...pluginNoExternal
|
|
265
|
+
];
|
|
266
|
+
}
|
|
267
|
+
function resolveEnvironmentServerConfig(env) {
|
|
268
|
+
if (!env.VITE_DEV_SERVER_KEY && !env.VITE_DEV_SERVER_CERT) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (!fs.existsSync(env.VITE_DEV_SERVER_KEY) || !fs.existsSync(env.VITE_DEV_SERVER_CERT)) {
|
|
272
|
+
throw Error(`Unable to find the certificate files specified in your environment. Ensure you have correctly configured VITE_DEV_SERVER_KEY: [${env.VITE_DEV_SERVER_KEY}] and VITE_DEV_SERVER_CERT: [${env.VITE_DEV_SERVER_CERT}].`);
|
|
273
|
+
}
|
|
274
|
+
const host = resolveHostFromEnv(env);
|
|
275
|
+
if (!host) {
|
|
276
|
+
throw Error(`Unable to determine the host from the environment's APP_URL: [${env.APP_URL}].`);
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
hmr: { host },
|
|
280
|
+
host,
|
|
281
|
+
https: {
|
|
282
|
+
key: fs.readFileSync(env.VITE_DEV_SERVER_KEY),
|
|
283
|
+
cert: fs.readFileSync(env.VITE_DEV_SERVER_CERT)
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function resolveHostFromEnv(env) {
|
|
288
|
+
try {
|
|
289
|
+
return new URL(env.APP_URL).host;
|
|
290
|
+
} catch {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function resolveDevelopmentEnvironmentServerConfig(host) {
|
|
295
|
+
if (host === false) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
const configPath = determineDevelopmentEnvironmentConfigPath();
|
|
299
|
+
host = host === true ? resolveDevelopmentEnvironmentHost(configPath) : host;
|
|
300
|
+
const keyPath = path.resolve(configPath, "certs", `${host}.key`);
|
|
301
|
+
const certPath = path.resolve(configPath, "certs", `${host}.crt`);
|
|
302
|
+
if (!fs.existsSync(keyPath) || !fs.existsSync(certPath)) {
|
|
303
|
+
throw Error(`Unable to find certificate files for your host [${host}] in the [${configPath}/certs] directory.`);
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
hmr: { host },
|
|
307
|
+
host,
|
|
308
|
+
https: {
|
|
309
|
+
key: fs.readFileSync(keyPath),
|
|
310
|
+
cert: fs.readFileSync(certPath)
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function determineDevelopmentEnvironmentConfigPath() {
|
|
315
|
+
const envConfigPath = path.resolve(process.cwd(), ".config");
|
|
316
|
+
if (fs.existsSync(envConfigPath)) {
|
|
317
|
+
return envConfigPath;
|
|
318
|
+
}
|
|
319
|
+
return path.resolve(process.cwd(), ".config");
|
|
320
|
+
}
|
|
321
|
+
function resolveDevelopmentEnvironmentHost(configPath) {
|
|
322
|
+
const configFile = path.resolve(configPath, "config.json");
|
|
323
|
+
if (!fs.existsSync(configFile)) {
|
|
324
|
+
throw Error(`Unable to find the configuration file [${configFile}]. You will need to manually specify the host in the \`detectTls\` configuration option.`);
|
|
325
|
+
}
|
|
326
|
+
const config = JSON.parse(fs.readFileSync(configFile, "utf-8"));
|
|
327
|
+
return path.basename(process.cwd()) + "." + config.tld;
|
|
328
|
+
}
|
|
329
|
+
function dirname() {
|
|
330
|
+
return fileURLToPath(new URL(".", import.meta.url));
|
|
331
|
+
}
|
|
332
|
+
export {
|
|
333
|
+
litestar as default,
|
|
334
|
+
refreshPaths
|
|
335
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolvePageComponent<T>(path: string, pages: Record<string, Promise<T> | (() => Promise<T>)>): Promise<T>;
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "litestar-vite-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Litestar plugin for Vite.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"litestar",
|
|
7
|
+
"vite",
|
|
8
|
+
"vite-plugin"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/litestar-org/vite-plugin",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/litestar-org/vite-plugin"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "Litestar",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./dist/index.mjs",
|
|
20
|
+
"require": "./dist/index.cjs",
|
|
21
|
+
"types": "./dist/index.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./inertia-helpers": {
|
|
24
|
+
"import": "./inertia-helpers/index.js",
|
|
25
|
+
"types": "./inertia-helpers/index.d.ts",
|
|
26
|
+
"node": "./inertia-helpers/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"/dist",
|
|
32
|
+
"/inertia-helpers"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "npm run build-plugin && npm run build-inertia-helpers",
|
|
36
|
+
"build-plugin": "rm -rf dist && npm run build-plugin-types && npm run build-plugin-esm && npm run build-plugin-cjs && cp src/dev-server-index.html dist/",
|
|
37
|
+
"build-plugin-types": "tsc --emitDeclarationOnly",
|
|
38
|
+
"build-plugin-cjs": "esbuild src/index.ts --platform=node --format=cjs --outfile=dist/index.cjs --define:import.meta.url=import_meta_url --inject:./import.meta.url-polyfill.js",
|
|
39
|
+
"build-plugin-esm": "esbuild src/index.ts --platform=node --format=esm --outfile=dist/index.mjs",
|
|
40
|
+
"build-inertia-helpers": "rm -rf inertia-helpers && tsc --project tsconfig.inertia-helpers.json",
|
|
41
|
+
"lint": "eslint --ext .ts ./src ./tests",
|
|
42
|
+
"test": "vitest run"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^18.11.9",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^5.21.0",
|
|
47
|
+
"@typescript-eslint/parser": "^5.21.0",
|
|
48
|
+
"esbuild": "0.16.10",
|
|
49
|
+
"eslint": "^8.14.0",
|
|
50
|
+
"typescript": "^4.6.4",
|
|
51
|
+
"vite": "^4.0.0",
|
|
52
|
+
"vitest": "^0.34.4"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"vite": "^3.0.0 || ^4.0.0"
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=14"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"picocolors": "^1.0.0",
|
|
62
|
+
"vite-plugin-full-reload": "^1.0.5"
|
|
63
|
+
}
|
|
64
|
+
}
|