Skip to content

Commit

Permalink
feat(vite): update vite configuration (#6102)
Browse files Browse the repository at this point in the history
  • Loading branch information
xcy960815 authored Feb 29, 2024
1 parent b2de698 commit 042c638
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 38 deletions.
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 : {}),
);

0 comments on commit 042c638

Please sign in to comment.