shrub/pkg/grid/vite.config.ts

42 lines
1.3 KiB
TypeScript
Raw Normal View History

import { loadEnv, defineConfig } from 'vite';
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
// https://vitejs.dev/config/
export default ({ mode }) => {
if (mode !== 'mock') {
// using current commit until release
const GIT_DESC = execSync('git rev-parse --short HEAD', { encoding: 'utf8' }).trim();
process.env.VITE_SHORTHASH = GIT_DESC;
} else {
process.env.VITE_SHORTHASH = '1';
}
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/',
server: mode === 'mock' ? undefined : { https: true },
build:
mode !== 'profile'
? undefined
: {
rollupOptions: {
plugins: [
analyze({
limit: 20
}),
visualizer()
]
}
},
plugins:
mode === 'mock' ? [] : [urbitPlugin({ base: 'grid', target: SHIP_URL }), reactRefresh()]
});
};