Skip to content

Commit

Permalink
Use iife to format the bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandraFlavia9 committed Jun 18, 2024
1 parent e4d4960 commit e95911e
Showing 1 changed file with 34 additions and 27 deletions.
61 changes: 34 additions & 27 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +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]',
format: 'iife',
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',
},
},
},
},
});
});
};

0 comments on commit e95911e

Please sign in to comment.