From 2d4692d3df7c4207de8117a7f5123977b3c5dfc3 Mon Sep 17 00:00:00 2001 From: alexandrabri Date: Wed, 19 Jun 2024 12:20:12 +0300 Subject: [PATCH] [Fix] Enable hotjar (#162) --- vite.config.ts | 60 ++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 6bf54c24..94663bfd 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,31 +3,39 @@ import react from '@vitejs/plugin-react-swc'; import EnvironmentPlugin from 'vite-plugin-environment'; // https://vitejs.dev/config/ -export default defineConfig({ - plugins: [react(), EnvironmentPlugin(['NODE_ENV', 'PREVIEW_ERROR_URL'])], - server: { - port: 3002, - }, - base: './', - optimizeDeps: { - include: ['@chili-publish/grafx-shared-components', '@chili-publish/studio-sdk'], - }, - resolve: { - // force Vite to always resolve listed dependencies to the same copy (from project root). - dedupe: ['react', 'react-dom'], - }, - build: { - emptyOutDir: true, - rollupOptions: { - input: { - index: './src/main.tsx', - bootstrap: './src/_dev-execution/bootstrap.ts', - }, - output: { - entryFileNames: 'bundle.js', - chunkFileNames: 'bundle.js', - assetFileNames: 'main.[ext]', +export default ({ mode }) => { + return defineConfig({ + plugins: [react(), EnvironmentPlugin(['NODE_ENV', 'PREVIEW_ERROR_URL'])], + server: { + port: 3002, + }, + base: './', + optimizeDeps: { + include: ['@chili-publish/grafx-shared-components', '@chili-publish/studio-sdk'], + }, + resolve: { + // force Vite to always resolve listed dependencies to the same copy (from project root). + dedupe: ['react', 'react-dom'], + }, + build: { + emptyOutDir: true, + rollupOptions: { + input: + mode === 'development' + ? { + index: './src/main.tsx', + bootstrap: './src/_dev-execution/bootstrap.ts', + } + : { + index: './src/main.tsx', + }, + output: { + entryFileNames: 'bundle.js', + chunkFileNames: 'bundle.js', + assetFileNames: 'main.[ext]', + format: 'iife', + }, }, }, - }, -}); + }); +};