49965e7786
Turns out the returned config is merged with the user config, so we don't have to do that ourselves.
26 lines
723 B
TypeScript
26 lines
723 B
TypeScript
import { Plugin } from 'vite';
|
|
import { InternalConfig } from '../types';
|
|
|
|
/**
|
|
* Defines global constants about the dev server. Helps scripts connect to the server's web socket.
|
|
*/
|
|
export function devServerGlobals(internalConfig: InternalConfig): Plugin {
|
|
return {
|
|
name: 'wxt:dev-server-globals',
|
|
config() {
|
|
if (internalConfig.server == null || internalConfig.command == 'build')
|
|
return;
|
|
|
|
return {
|
|
define: {
|
|
__DEV_SERVER_PROTOCOL__: JSON.stringify('ws:'),
|
|
__DEV_SERVER_HOSTNAME__: JSON.stringify(
|
|
internalConfig.server.hostname,
|
|
),
|
|
__DEV_SERVER_PORT__: JSON.stringify(internalConfig.server.port),
|
|
},
|
|
};
|
|
},
|
|
};
|
|
}
|