Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] implement custom dev server #3

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ module.exports = function defineShipwrightHook(sails) {
chunkSplit: {
strategy: 'all-in-one'
}
},
server: {
port: sails.config.port,
strictPort: true,
printUrls: false
}
})
const config = mergeRsbuildConfig(
Expand All @@ -78,7 +83,20 @@ module.exports = function defineShipwrightHook(sails) {
if (process.env.NODE_ENV == 'production') {
rsbuild.build()
} else {
rsbuild.build({ mode: 'development', watch: true })
const rsbuildDevServer = await rsbuild.createDevServer()
sails.after('hook:http:loaded', async () => {
sails.hooks.http.app.use(rsbuildDevServer.middlewares)
sails.hooks.http.server.on(
'upgrade',
rsbuildDevServer.onHTTPUpgrade
)
})
sails.on('lifted', async () => {
await rsbuildDevServer.afterListen()
})
sails.on('lower', async () => {
await rsbuildDevServer.close()
})
}
} catch (error) {
sails.error(error)
Expand Down
Loading
Loading