Skip to content
Open
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
2 changes: 1 addition & 1 deletion packages/dev-server-core/src/server/addPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function addPlugins(logger: Logger, config: DevServerCoreConfig) {
}

if (config.injectWebSocket && config.plugins?.some(pl => pl.injectWebSocket)) {
config.plugins.unshift(webSocketsPlugin());
config.plugins.unshift(webSocketsPlugin(config.basePath));
}

if (config.plugins?.some(pl => 'resolveImport' in pl || 'transformImport' in pl)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/dev-server-core/src/web-sockets/webSocketsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { appendToDocument, isHtmlFragment } from '@web/parse5-utils';
export const webSocketScript = `<!-- injected by web-dev-server -->
<script type="module" src="${NAME_WEB_SOCKET_IMPORT}"></script>`;

export function webSocketsPlugin(): Plugin {
export function webSocketsPlugin(basePath?: string): Plugin {
return {
name: 'web-sockets',

Expand Down Expand Up @@ -128,7 +128,7 @@ export function webSocketsPlugin(): Plugin {


const { protocol, host } = new URL(import.meta.url);
const webSocketUrl = \`ws\${protocol === 'https:' ? 's' : ''}://\${host}/${NAME_WEB_SOCKET_API}\`;
const webSocketUrl = \`ws\${protocol === 'https:' ? 's' : ''}://\${host}/${basePath ? basePath + '/' : ''}${NAME_WEB_SOCKET_API}\`;

export let webSocket;
export let webSocketOpened;
Expand Down