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

Exporting vite config with UserConfigFnObject type build error #384

Closed
9 tasks done
rom-sky-blue opened this issue Apr 2, 2024 · 1 comment
Closed
9 tasks done

Comments

@rom-sky-blue
Copy link

Related plugins

Describe the bug

I created the following configuration file with reference to the following document in order to use environment variables in the configuration.
https://vitejs.dev/config/

vite.config.ts

/// <reference types="vitest" />

import { fileURLToPath, URL } from 'node:url';
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), '');
  return {
    // vite の設定
    plugins: [vue(), vueJsx()],
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url)),
      },
    },
    test: {
      globals: true,
    },
    server: {
      proxy: {
        '/api': {
          target: env.VITE_API_URL,
          changeOrigin: true,
          rewrite: (path) => path.replace('/api', ''),
        },
      },
    },
  };
});

It appears to work fine in development mode, but
I get the following TypeScritpt error when I build

vitest.config.ts:6:3 - error TS2345: Argument of type 'UserConfigFnObject' is not assignable to parameter of type 'never'.

The same error occurs when I format it as shown in the following post.
vitejs/vite#13950

Reproduction

https://stackblitz.com/edit/vitejs-vite-osther?file=index.html&terminal=dev

Steps to reproduce

Only build script make

System Info

yarn create vue@5.0.10

Used Package Manager

yarn

Logs

No response

Validations

Copy link

Hello @rom-sky-blue. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 28, 2024
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