@adonisjs/vite 0.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 +9 -0
- package/README.md +36 -0
- package/build/configure.d.ts +3 -0
- package/build/configure.d.ts.map +1 -0
- package/build/configure.js +13 -0
- package/build/index.d.ts +5 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +4 -0
- package/build/providers/vite_provider.d.ts +10 -0
- package/build/providers/vite_provider.d.ts.map +1 -0
- package/build/providers/vite_provider.js +48 -0
- package/build/services/vite.d.ts +4 -0
- package/build/services/vite.d.ts.map +1 -0
- package/build/services/vite.js +6 -0
- package/build/src/backend/types/extended.d.ts +7 -0
- package/build/src/backend/types/extended.d.ts.map +1 -0
- package/build/src/backend/types/extended.js +1 -0
- package/build/src/backend/types/main.d.ts +9 -0
- package/build/src/backend/types/main.d.ts.map +1 -0
- package/build/src/backend/types/main.js +1 -0
- package/build/src/backend/utils.d.ts +2 -0
- package/build/src/backend/utils.d.ts.map +1 -0
- package/build/src/backend/utils.js +7 -0
- package/build/src/backend/vite.d.ts +19 -0
- package/build/src/backend/vite.d.ts.map +1 -0
- package/build/src/backend/vite.js +182 -0
- package/build/src/vite_plugin/config.d.ts +5 -0
- package/build/src/vite_plugin/config.d.ts.map +1 -0
- package/build/src/vite_plugin/config.js +47 -0
- package/build/src/vite_plugin/config_resolver.d.ts +9 -0
- package/build/src/vite_plugin/config_resolver.d.ts.map +1 -0
- package/build/src/vite_plugin/config_resolver.js +27 -0
- package/build/src/vite_plugin/helpers/inertia.d.ts +2 -0
- package/build/src/vite_plugin/helpers/inertia.d.ts.map +1 -0
- package/build/src/vite_plugin/helpers/inertia.js +11 -0
- package/build/src/vite_plugin/hot_file.d.ts +9 -0
- package/build/src/vite_plugin/hot_file.d.ts.map +1 -0
- package/build/src/vite_plugin/hot_file.js +30 -0
- package/build/src/vite_plugin/index.d.ts +4 -0
- package/build/src/vite_plugin/index.d.ts.map +1 -0
- package/build/src/vite_plugin/index.js +16 -0
- package/build/src/vite_plugin/types/index.d.ts +10 -0
- package/build/src/vite_plugin/types/index.d.ts.map +1 -0
- package/build/src/vite_plugin/types/index.js +1 -0
- package/build/src/vite_plugin/utils.d.ts +5 -0
- package/build/src/vite_plugin/utils.d.ts.map +1 -0
- package/build/src/vite_plugin/utils.js +16 -0
- package/build/stubs/index.d.ts +2 -0
- package/build/stubs/index.d.ts.map +1 -0
- package/build/stubs/index.js +2 -0
- package/build/stubs/vite/vite_config.stub +14 -0
- package/configure.ts +30 -0
- package/index.ts +15 -0
- package/package.json +147 -0
- package/providers/vite_provider.ts +89 -0
- package/services/vite.ts +23 -0
- package/src/backend/types/extended.ts +19 -0
- package/src/backend/types/main.ts +31 -0
- package/src/backend/utils.ts +19 -0
- package/src/backend/vite.ts +367 -0
- package/src/vite_plugin/config.ts +97 -0
- package/src/vite_plugin/config_resolver.ts +62 -0
- package/src/vite_plugin/helpers/inertia.ts +27 -0
- package/src/vite_plugin/hot_file.ts +59 -0
- package/src/vite_plugin/index.ts +38 -0
- package/src/vite_plugin/types/index.ts +56 -0
- package/src/vite_plugin/utils.ts +40 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @adonisjs/vite
|
|
3
|
+
*
|
|
4
|
+
* (c) AdonisJS
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { AddressInfo } from 'node:net'
|
|
11
|
+
import { ResolvedConfig } from 'vite'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the dev server URL from the server address and configuration.
|
|
15
|
+
*/
|
|
16
|
+
export const resolveDevServerUrl = (address: AddressInfo, config: ResolvedConfig) => {
|
|
17
|
+
const configHmrProtocol =
|
|
18
|
+
typeof config.server.hmr === 'object' ? config.server.hmr.protocol : null
|
|
19
|
+
|
|
20
|
+
const clientProtocol = configHmrProtocol ? (configHmrProtocol === 'wss' ? 'https' : 'http') : null
|
|
21
|
+
const serverProtocol = config.server.https ? 'https' : 'http'
|
|
22
|
+
const protocol = clientProtocol ?? serverProtocol
|
|
23
|
+
|
|
24
|
+
const configHmrHost = typeof config.server.hmr === 'object' ? config.server.hmr.host : null
|
|
25
|
+
const configHost = typeof config.server.host === 'string' ? config.server.host : null
|
|
26
|
+
|
|
27
|
+
let host = configHmrHost ?? configHost ?? address.address
|
|
28
|
+
if (host === '::1') {
|
|
29
|
+
host = 'localhost'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return `${protocol}://${host}:${address.port}`
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Add a trailing slash if missing
|
|
37
|
+
*/
|
|
38
|
+
export const addTrailingSlash = (url: string) => {
|
|
39
|
+
return url.endsWith('/') ? url : url + '/'
|
|
40
|
+
}
|