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-08-26 03:14:48 +03:00
|
|
|
import htmlPlugin from 'vite-plugin-html-config';
|
|
|
|
|
|
|
|
const htmlPluginOpt = {
|
|
|
|
headScripts: [{ src: '/apps/grid/desk.js' }, { src: '/session.js' }]
|
|
|
|
};
|
2021-08-14 02:11:16 +03:00
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
2021-08-31 20:57:11 +03:00
|
|
|
export default ({ mode }) => {
|
|
|
|
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
|
|
|
|
: {
|
|
|
|
proxy: {
|
|
|
|
'^/apps/grid/desk.js': {
|
|
|
|
target: SHIP_URL
|
|
|
|
},
|
|
|
|
'^((?!/apps/grid).)*$': {
|
|
|
|
target: SHIP_URL
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
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
|
|
|
},
|
|
|
|
plugins: [htmlPlugin(htmlPluginOpt), reactRefresh()]
|
|
|
|
});
|
|
|
|
};
|