1
0

vite.config.mts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import path from 'path';
  2. import { pathToFileURL } from 'url';
  3. import { loadEnv } from 'vite';
  4. import { defineConfig } from 'vitest/config';
  5. import { vendureDashboardPlugin } from './vite/vite-plugin-vendure-dashboard.js';
  6. /**
  7. * This config is used for local development
  8. */
  9. export default ({ mode }: { mode: string }) => {
  10. process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
  11. const adminApiHost = process.env.VITE_ADMIN_API_HOST ?? 'http://localhost';
  12. const adminApiPort = process.env.VITE_ADMIN_API_PORT ? +process.env.VITE_ADMIN_API_PORT : 'auto';
  13. process.env.IS_LOCAL_DEV = adminApiHost.includes('localhost') ? 'true' : 'false';
  14. const vendureConfigPath = process.env.VITEST
  15. ? // This should always be used for running the tests
  16. './sample-vendure-config.ts'
  17. : // This one might be changed to '../dev-server/dev-config.ts' to test ui extensions
  18. './sample-vendure-config.ts';
  19. return defineConfig({
  20. test: {
  21. globals: true,
  22. environment: 'jsdom',
  23. exclude: ['./plugin/**/*', '**/node_modules/**/*'],
  24. },
  25. plugins: [
  26. vendureDashboardPlugin({
  27. vendureConfigPath: pathToFileURL(vendureConfigPath),
  28. api: { host: adminApiHost, port: adminApiPort },
  29. tempCompilationDir: path.resolve(__dirname, './.temp'),
  30. }) as any,
  31. ],
  32. });
  33. };