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

feat(vite): update vite configuration #6102

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 0 additions & 38 deletions vite.config.js

This file was deleted.

49 changes: 49 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { defineConfig } from 'vite';
import type { UserConfig } from 'vite';
import { deepMix } from '@antv/util';
const { LINK, MODULE } = process.env;

if (LINK === '1' && !MODULE) {
throw new Error(
`Please specify MODULE, for example: $ MODULE=@antv/component npm run dev:link.`,
);
}

/**
* @desc Deeply merge user config into default config
* @link https://vitejs.dev/config/
* @type {import('vite').UserConfig}
*/
const baseOptions: UserConfig = {
root: './__tests__/',
server: {
port: 8080,
open: '/',
},
build: { outDir: '../' },
};

/**
* @desc Link configuration
* @link https://vitejs.dev/config/
* @type {import('vite').UserConfig}
*/
const linkOptions: UserConfig = {
server: {
watch: {
ignored: [`!**/node_modules/${MODULE}/**`],
},
},
optimizeDeps: {
exclude: [`${MODULE}`],
},
};

/**
* @desc Vite configuration
* @link https://vitejs.dev/config/
* @type {import('vite').UserConfig}
*/
export default defineConfig(
deepMix(baseOptions, LINK === '1' ? linkOptions : {}),
);