fix: Fix config hook implementations for vite plugins
Turns out the returned config is merged with the user config, so we don't have to do that ourselves.
This commit is contained in:
@@ -11,20 +11,17 @@ export function devHtmlPrerender(config: InternalConfig): vite.Plugin {
|
||||
return {
|
||||
apply: 'build',
|
||||
name: 'wxt:dev-html-prerender',
|
||||
config(userConfig) {
|
||||
return vite.mergeConfig(
|
||||
{
|
||||
resolve: {
|
||||
alias: {
|
||||
'@wxt/reload-html': resolve(
|
||||
config.root,
|
||||
'node_modules/wxt/dist/virtual-modules/reload-html.js',
|
||||
),
|
||||
},
|
||||
config() {
|
||||
return {
|
||||
resolve: {
|
||||
alias: {
|
||||
'@wxt/reload-html': resolve(
|
||||
config.root,
|
||||
'node_modules/wxt/dist/virtual-modules/reload-html.js',
|
||||
),
|
||||
},
|
||||
},
|
||||
userConfig,
|
||||
);
|
||||
};
|
||||
},
|
||||
async transform(html, id) {
|
||||
const server = config.server;
|
||||
|
||||
@@ -7,18 +7,19 @@ import { InternalConfig } from '../types';
|
||||
export function devServerGlobals(internalConfig: InternalConfig): Plugin {
|
||||
return {
|
||||
name: 'wxt:dev-server-globals',
|
||||
config(config) {
|
||||
config() {
|
||||
if (internalConfig.server == null || internalConfig.command == 'build')
|
||||
return;
|
||||
|
||||
config.define ??= {};
|
||||
config.define.__DEV_SERVER_PROTOCOL__ = JSON.stringify('ws:');
|
||||
config.define.__DEV_SERVER_HOSTNAME__ = JSON.stringify(
|
||||
internalConfig.server.hostname,
|
||||
);
|
||||
config.define.__DEV_SERVER_PORT__ = JSON.stringify(
|
||||
internalConfig.server.port,
|
||||
);
|
||||
return {
|
||||
define: {
|
||||
__DEV_SERVER_PROTOCOL__: JSON.stringify('ws:'),
|
||||
__DEV_SERVER_HOSTNAME__: JSON.stringify(
|
||||
internalConfig.server.hostname,
|
||||
),
|
||||
__DEV_SERVER_PORT__: JSON.stringify(internalConfig.server.port),
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user