2021-08-31 20:57:11 +03:00
|
|
|
import { loadEnv, defineConfig } from 'vite';
|
2021-08-14 02:11:16 +03:00
|
|
|
import analyze from 'rollup-plugin-analyzer';
|
|
|
|
import { visualizer } from 'rollup-plugin-visualizer';
|
|
|
|
import reactRefresh from '@vitejs/plugin-react-refresh';
|
2021-09-24 07:41:56 +03:00
|
|
|
import { urbitPlugin } from '@urbit/vite-plugin-urbit';
|
2021-09-20 22:54:50 +03:00
|
|
|
import { execSync } from 'child_process';
|
2021-08-26 03:14:48 +03:00
|
|
|
|
2021-08-14 02:11:16 +03:00
|
|
|
// https://vitejs.dev/config/
|
2021-08-31 20:57:11 +03:00
|
|
|
export default ({ mode }) => {
|
2021-10-21 02:48:42 +03:00
|
|
|
process.env.VITE_STORAGE_VERSION = Date.now().toString();
|
2021-09-25 23:32:37 +03:00
|
|
|
|
2021-08-31 20:57:11 +03:00
|
|
|
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({
|
|
|
|
base: mode === 'mock' ? undefined : '/apps/grid/',
|
2021-09-25 23:32:37 +03:00
|
|
|
server: mode === 'mock' ? undefined : { https: true },
|
2021-08-31 20:57:11 +03:00
|
|
|
build:
|
|
|
|
mode !== 'profile'
|
|
|
|
? undefined
|
|
|
|
: {
|
|
|
|
rollupOptions: {
|
|
|
|
plugins: [
|
|
|
|
analyze({
|
|
|
|
limit: 20
|
|
|
|
}),
|
|
|
|
visualizer()
|
|
|
|
]
|
2021-08-14 02:11:16 +03:00
|
|
|
}
|
2021-08-31 20:57:11 +03:00
|
|
|
},
|
2021-09-25 23:32:37 +03:00
|
|
|
plugins:
|
2021-10-21 22:22:37 +03:00
|
|
|
mode === 'mock'
|
|
|
|
? []
|
|
|
|
: [urbitPlugin({ base: 'grid', target: SHIP_URL, secure: false }), reactRefresh()]
|
2021-08-31 20:57:11 +03:00
|
|
|
});
|
|
|
|
};
|