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