landscape/ui/vite.config.ts

62 lines
1.6 KiB
TypeScript
Raw Normal View History

import packageJson from './package.json';
import { loadEnv, defineConfig } from 'vite';
import analyze from 'rollup-plugin-analyzer';
import { visualizer } from 'rollup-plugin-visualizer';
2023-05-17 00:35:10 +03:00
import react from '@vitejs/plugin-react';
import { urbitPlugin } from '@urbit/vite-plugin-urbit';
import { fileURLToPath } from 'url';
2023-05-17 00:35:10 +03:00
import basicSsl from '@vitejs/plugin-basic-ssl';
// https://vitejs.dev/config/
export default ({ mode }) => {
process.env.VITE_STORAGE_VERSION =
mode === 'development' ? Date.now().toString() : packageJson.version;
Object.assign(process.env, loadEnv(mode, process.cwd()));
const SHIP_URL =
process.env.SHIP_URL ||
process.env.VITE_SHIP_URL ||
'http://localhost:8080';
console.log(SHIP_URL);
return defineConfig({
2023-07-13 20:46:44 +03:00
base: mode === 'mock' ? undefined : '/apps/landscape/',
server: mode === 'mock' ? undefined : { https: true },
build:
mode !== 'profile'
2022-08-25 22:58:09 +03:00
? {
rollupOptions: {
external: 'node-fetch',
},
2022-08-25 22:58:09 +03:00
}
: {
rollupOptions: {
plugins: [
analyze({
limit: 20,
}),
visualizer(),
],
},
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
plugins:
mode === 'mock'
2023-05-17 00:35:10 +03:00
? [basicSsl(), react()]
2022-08-25 22:58:09 +03:00
: [
2023-05-17 00:35:10 +03:00
basicSsl(),
urbitPlugin({
2023-07-13 20:46:44 +03:00
base: 'landscape',
target: SHIP_URL,
changeOrigin: true,
secure: false,
}),
2023-05-17 00:35:10 +03:00
react(),
],
});
};