2024-02-13 11:51:44 +00:00
|
|
|
/// <reference types="vitest" />
|
|
|
|
import react from '@vitejs/plugin-react-swc';
|
|
|
|
import path from 'path';
|
|
|
|
import { visualizer } from 'rollup-plugin-visualizer';
|
|
|
|
import type { PluginOption } from 'vite';
|
2023-04-28 05:44:27 +00:00
|
|
|
import { defineConfig } from 'vite';
|
2024-02-13 11:51:44 +00:00
|
|
|
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
|
|
|
|
import dts from 'vite-plugin-dts';
|
|
|
|
import eslint from 'vite-plugin-eslint';
|
|
|
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
2022-09-16 17:18:15 +00:00
|
|
|
|
|
|
|
export default defineConfig(({ mode }) => {
|
2023-04-28 05:44:27 +00:00
|
|
|
if (mode === 'package') {
|
2024-02-13 11:51:44 +00:00
|
|
|
return {
|
|
|
|
base: './',
|
|
|
|
plugins: [
|
|
|
|
react(),
|
|
|
|
eslint(),
|
|
|
|
tsconfigPaths(),
|
|
|
|
visualizer() as unknown as PluginOption,
|
|
|
|
dts({
|
|
|
|
insertTypesEntry: true,
|
|
|
|
}),
|
|
|
|
cssInjectedByJsPlugin(),
|
|
|
|
],
|
|
|
|
build: {
|
|
|
|
cssCodeSplit: true,
|
|
|
|
lib: {
|
2024-02-20 22:44:16 +00:00
|
|
|
entry: path.resolve(__dirname, './src/index.ts'),
|
2024-02-13 11:51:44 +00:00
|
|
|
name: 'InvokeAIUI',
|
|
|
|
fileName: (format) => `invoke-ai-ui.${format}.js`,
|
|
|
|
},
|
|
|
|
rollupOptions: {
|
|
|
|
external: ['react', 'react-dom', '@emotion/react', '@chakra-ui/react', '@invoke-ai/ui-library'],
|
|
|
|
output: {
|
|
|
|
globals: {
|
|
|
|
react: 'React',
|
|
|
|
'react-dom': 'ReactDOM',
|
|
|
|
'@emotion/react': 'EmotionReact',
|
|
|
|
'@invoke-ai/ui-library': 'UiLibrary',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2024-02-20 22:44:16 +00:00
|
|
|
app: path.resolve(__dirname, './src/app'),
|
|
|
|
assets: path.resolve(__dirname, './src/assets'),
|
|
|
|
common: path.resolve(__dirname, './src/common'),
|
|
|
|
features: path.resolve(__dirname, './src/features'),
|
|
|
|
services: path.resolve(__dirname, './src/services'),
|
|
|
|
theme: path.resolve(__dirname, './src/theme'),
|
2024-02-13 11:51:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2022-09-16 17:18:15 +00:00
|
|
|
}
|
2023-04-28 05:44:27 +00:00
|
|
|
|
2024-02-13 11:51:44 +00:00
|
|
|
return {
|
|
|
|
base: './',
|
2024-02-24 06:01:38 +00:00
|
|
|
plugins: [
|
|
|
|
react(),
|
|
|
|
mode !== 'test' && eslint({ failOnError: mode === 'production', failOnWarning: mode === 'production' }),
|
|
|
|
tsconfigPaths(),
|
|
|
|
visualizer() as unknown as PluginOption,
|
|
|
|
],
|
2024-02-13 11:51:44 +00:00
|
|
|
build: {
|
|
|
|
chunkSizeWarningLimit: 1500,
|
|
|
|
},
|
|
|
|
server: {
|
|
|
|
// Proxy HTTP requests to the flask server
|
|
|
|
proxy: {
|
|
|
|
// Proxy socket.io to the nodes socketio server
|
|
|
|
'/ws/socket.io': {
|
|
|
|
target: 'ws://127.0.0.1:9090',
|
|
|
|
ws: true,
|
|
|
|
},
|
|
|
|
// Proxy openapi schema definiton
|
|
|
|
'/openapi.json': {
|
|
|
|
target: 'http://127.0.0.1:9090/openapi.json',
|
|
|
|
rewrite: (path) => path.replace(/^\/openapi.json/, ''),
|
|
|
|
changeOrigin: true,
|
|
|
|
},
|
|
|
|
// proxy nodes api
|
2024-02-16 10:57:30 +00:00
|
|
|
'/api/': {
|
|
|
|
target: 'http://127.0.0.1:9090/api/',
|
|
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
2024-02-13 11:51:44 +00:00
|
|
|
changeOrigin: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
test: {
|
2024-02-15 11:16:11 +00:00
|
|
|
typecheck: {
|
|
|
|
enabled: true,
|
|
|
|
ignoreSourceErrors: true,
|
|
|
|
},
|
2024-05-04 22:11:26 +00:00
|
|
|
coverage: {
|
|
|
|
provider: 'v8',
|
|
|
|
all: false,
|
|
|
|
reporter: ['html'],
|
|
|
|
},
|
2024-02-13 11:51:44 +00:00
|
|
|
},
|
|
|
|
};
|
2022-09-16 17:18:15 +00:00
|
|
|
});
|