Skip to content

Commit f176eb3

Browse files
author
pooya parsa
committed
feat: altPort option and disable for codesandbox
1 parent e9df914 commit f176eb3

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

packages/loading/lib/module.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,27 @@ module.exports = function NuxtLoadingScreen () {
55
return
66
}
77

8+
const baseURL = nuxt.options.router.base + '_loading'
9+
nuxt.options._loadingScreenBaseURL = baseURL
10+
811
const LoadingUI = require('./loading')
912

10-
const loading = new LoadingUI({
11-
baseURL: nuxt.options.router.base + '_loading'
12-
})
13+
const loading = new LoadingUI({ baseURL })
1314

1415
nuxt.options.serverMiddleware.push({
1516
path: '/_loading',
1617
handler: (req, res) => { loading.app(req, res) }
1718
})
1819

19-
nuxt.hook('listen', async (_, { url }) => {
20-
await loading.initAlt({ url })
21-
nuxt.options._loadingScreenBaseURL = loading.baseURLAlt
22-
})
20+
if (
21+
nuxt.options.loading.altPort !== false &&
22+
!process.env.CODESANDBOX_SSE
23+
) {
24+
nuxt.hook('listen', async (_, { url }) => {
25+
await loading.initAlt({ url })
26+
nuxt.options._loadingScreenBaseURL = loading.baseURLAlt
27+
})
28+
}
2329

2430
nuxt.hook('close', async () => {
2531
await loading.close()

0 commit comments

Comments
 (0)