@wix/origami-site-express 0.1.3 → 0.1.4
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/package.json +2 -2
- package/src/adapter/driver.js +1 -1
- package/src/server/dev.js +2 -2
- package/src/server/env.js +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/origami-site-express",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Run an exported Wix origami site on Node with Express and Vite.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
]
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
|
-
"falconPackageHash": "
|
|
68
|
+
"falconPackageHash": "c747f0aab95a2845e2ad63b387beb5dde7b4e28c62baceff7b05fc63"
|
|
69
69
|
}
|
package/src/adapter/driver.js
CHANGED
|
@@ -12,7 +12,7 @@ async function spawnBin(command, root, env) {
|
|
|
12
12
|
const { spawn } = await import('node:child_process')
|
|
13
13
|
const child = spawn(process.execPath, [binPath(root), command], {
|
|
14
14
|
cwd: root, stdio: ['ignore', 'pipe', 'pipe'],
|
|
15
|
-
env: { ...process.env, ...env, ...(command === '
|
|
15
|
+
env: { ...process.env, ...env, ...(command === 'dev' ? {} : { NODE_ENV: 'production' }) },
|
|
16
16
|
})
|
|
17
17
|
let output = ''
|
|
18
18
|
child.stdout.on('data', chunk => { output += chunk })
|
package/src/server/dev.js
CHANGED
|
@@ -12,7 +12,7 @@ import { createCurrentSite } from './currentSite.js'
|
|
|
12
12
|
/** `origami-site-express dev`: Vite in middleware mode, Express, and the core in dev mode, all live.
|
|
13
13
|
* @param {{ root: string }} options */
|
|
14
14
|
export async function dev({ root }) {
|
|
15
|
-
const env = loadEnv('development', root, ['VITE_', 'ORIGAMI_'])
|
|
15
|
+
const env = loadEnv('development', root, ['VITE_', 'ORIGAMI_', 'PORT', 'HOST'])
|
|
16
16
|
const { errorResponse, serializePageData } = await importCoreServer(root)
|
|
17
17
|
const { origamiVitePlugins } = await importCoreBuild(root)
|
|
18
18
|
const node = await importCoreNode(root)
|
|
@@ -47,5 +47,5 @@ export async function dev({ root }) {
|
|
|
47
47
|
})), resolution.embeds),
|
|
48
48
|
}))
|
|
49
49
|
httpServer.on('request', app)
|
|
50
|
-
await serve(httpServer, { port: port(), host: host('dev'), onClose: async () => { await vite.close(); await site()?.close() } })
|
|
50
|
+
await serve(httpServer, { port: port(env), host: host('dev', env), onClose: async () => { await vite.close(); await site()?.close() } })
|
|
51
51
|
}
|
package/src/server/env.js
CHANGED
|
@@ -7,9 +7,10 @@ export function siteOptions(env) {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** An empty PORT= means the default, not a random port. @param {Record<string, string | undefined>} [env] */
|
|
11
|
+
export const port = (env = process.env) => Number(env.PORT || 3000)
|
|
11
12
|
|
|
12
13
|
/** Dev serves the site's source through Vite, so it stays on this machine unless HOST says otherwise.
|
|
13
14
|
* 127.0.0.1, not localhost: on macOS localhost binds only ::1. Start listens on every interface so the deployed site is reachable.
|
|
14
|
-
* @param {'dev' | 'prod'} mode */
|
|
15
|
-
export const host = mode
|
|
15
|
+
* @param {'dev' | 'prod'} mode @param {Record<string, string | undefined>} [env] */
|
|
16
|
+
export const host = (mode, env = process.env) => env.HOST || (mode === 'dev' ? '127.0.0.1' : undefined)
|