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

customLogger can't be adjusted via plugin #10940

Closed
leonheess opened this issue Nov 15, 2022 · 1 comment
Closed

customLogger can't be adjusted via plugin #10940

leonheess opened this issue Nov 15, 2022 · 1 comment

Comments

@leonheess
Copy link

leonheess commented Nov 15, 2022

Describe the bug

One can easily change the vite config of an app by loading a plugin that uses the config hook. However, this does not work for the customLogger property for some reason.

Reproduction

https://stackblitz.com/edit/vitejs-vite-gechfp?file=vite.config.ts&view=editor

Steps to reproduce

Run the app and observe no changes to the log output. Modify customLogger directly (commented out) and it works.

import { createLogger, defineConfig, LogOptions } from 'vite';

const logger = createLogger();
const customLogger = {
  ...logger,
  info: (msg: string, options?: LogOptions) =>
    logger.info('Hi! I was inserted.\n' + msg, options),
};

const customServer = {
  port: 666,
};

export default defineConfig({
  plugins: [
    (() => ({
      name: 'logger-changer',
      config: () => ({
        server: customServer, // <-- works
        customLogger, // <-- doesn't work
      }),
    }))(),
  ],
});

/* this works for some reason
export default defineConfig({
  server: customServer, // <-- works
  customLogger, // <-- works
  }
});
*/
@bluwy
Copy link
Member

bluwy commented Nov 15, 2022

This is fixed in #10787. It should be available in the latest Vite 4 alpha release now.

@bluwy bluwy closed this as completed Nov 15, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Nov 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants