@platformatic/vite 2.2.0 → 2.2.2-alpha.1

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.
Files changed (3) hide show
  1. package/index.js +21 -37
  2. package/package.json +7 -7
  3. package/schema.json +1 -1
package/index.js CHANGED
@@ -125,29 +125,14 @@ export class ViteStackable extends BaseStackable {
125
125
  }
126
126
 
127
127
  getMeta () {
128
- let composer = { prefix: this.servicePrefix, wantsAbsoluteUrls: true, needsRootRedirect: true }
129
-
130
- if (this.isProduction) {
131
- composer = {
132
- tcp: typeof this.url !== 'undefined',
133
- url: this.url,
134
- prefix: (this.subprocessConfig?.base ?? this.#basePath).replace(/(^\/)|(\/$)/g, ''),
135
- wantsAbsoluteUrls: true,
136
- needsRootRedirect: true
137
- }
138
- } else if (this.url) {
139
- if (!this.#basePath) {
140
- const config = this.subprocessConfig ?? this.#app.config
141
- this.#basePath = config.base.replace(/(^\/)|(\/$)/g, '')
142
- }
143
-
144
- composer = {
145
- tcp: true,
146
- url: this.url,
147
- prefix: this.#basePath.replace(/(^\/)|(\/$)/g, ''),
148
- wantsAbsoluteUrls: true,
149
- needsRootRedirect: true
150
- }
128
+ const config = this.subprocessConfig ?? this.#app?.config
129
+
130
+ const composer = {
131
+ tcp: typeof this.url !== 'undefined',
132
+ url: this.url,
133
+ prefix: this.basePath ?? config?.base ?? this.#basePath,
134
+ wantsAbsoluteUrls: true,
135
+ needsRootRedirect: true
151
136
  }
152
137
 
153
138
  return { composer }
@@ -187,7 +172,10 @@ export class ViteStackable extends BaseStackable {
187
172
  }
188
173
 
189
174
  // Require Vite
190
- const serverPromise = createServerListener((this.isEntrypoint ? serverOptions?.port : undefined) ?? true)
175
+ const serverPromise = createServerListener(
176
+ (this.isEntrypoint ? serverOptions?.port : undefined) ?? true,
177
+ (this.isEntrypoint ? serverOptions?.hostname : undefined) ?? true
178
+ )
191
179
  const { createServer } = await importFile(resolve(this.#vite, 'dist/node/index.js'))
192
180
 
193
181
  // Create the server and listen
@@ -367,20 +355,16 @@ export class ViteSSRStackable extends NodeStackable {
367
355
  getMeta () {
368
356
  let composer = { prefix: this.servicePrefix, wantsAbsoluteUrls: true, needsRootRedirect: true }
369
357
 
370
- if (this.url) {
371
- if (!this.#basePath) {
372
- const application = this._getApplication()
373
- const config = application.vite.devServer?.config ?? application.vite.config.vite
374
- this.#basePath = (config.base ?? '').replace(/(^\/)|(\/$)/g, '')
375
- }
358
+ const vite = this._getApplication()?.vite
359
+ const config = vite?.devServer?.config ?? vite?.config.vite
360
+ const applicationBasePath = config?.base
376
361
 
377
- composer = {
378
- tcp: true,
379
- url: this.url,
380
- prefix: this.#basePath ?? this.servicePrefix,
381
- wantsAbsoluteUrls: true,
382
- needsRootRedirect: true
383
- }
362
+ composer = {
363
+ tcp: typeof this.url !== 'undefined',
364
+ url: this.url,
365
+ prefix: this.basePath ?? applicationBasePath ?? this.#basePath,
366
+ wantsAbsoluteUrls: true,
367
+ needsRootRedirect: true
384
368
  }
385
369
 
386
370
  return { composer }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/vite",
3
- "version": "2.2.0",
3
+ "version": "2.2.2-alpha.1",
4
4
  "description": "Platformatic Vite Stackable",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -18,10 +18,10 @@
18
18
  "@fastify/static": "^8.0.0",
19
19
  "fastify": "^5.0.0",
20
20
  "semver": "^7.6.3",
21
- "@platformatic/basic": "2.2.0",
22
- "@platformatic/config": "2.2.0",
23
- "@platformatic/utils": "2.2.0",
24
- "@platformatic/node": "2.2.0"
21
+ "@platformatic/basic": "2.2.2-alpha.1",
22
+ "@platformatic/utils": "2.2.2-alpha.1",
23
+ "@platformatic/config": "2.2.2-alpha.1",
24
+ "@platformatic/node": "2.2.2-alpha.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@fastify/vite": "^7.0.1",
@@ -34,8 +34,8 @@
34
34
  "typescript": "^5.5.4",
35
35
  "vite": "^5.4.0",
36
36
  "ws": "^8.18.0",
37
- "@platformatic/composer": "2.2.0",
38
- "@platformatic/service": "2.2.0"
37
+ "@platformatic/service": "2.2.2-alpha.1",
38
+ "@platformatic/composer": "2.2.2-alpha.1"
39
39
  },
40
40
  "scripts": {
41
41
  "test": "npm run lint && borp --concurrency=1 --no-timeout",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/vite/2.2.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/vite/2.2.2-alpha.1.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Vite Stackable",
5
5
  "type": "object",