From d7640c56910c7776542adb0b74d754f5e85012a3 Mon Sep 17 00:00:00 2001 From: Harsh Mahajan <127186841+HarshMN2345@users.noreply.github.com> Date: Sat, 19 Oct 2024 17:48:09 +0530 Subject: [PATCH] Create vite.config.js changing the build package --- lib/vite.config.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 lib/vite.config.js diff --git a/lib/vite.config.js b/lib/vite.config.js new file mode 100644 index 0000000..c60a34b --- /dev/null +++ b/lib/vite.config.js @@ -0,0 +1,43 @@ +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; +import path from 'path'; + +export default defineConfig(({ mode }) => { + const isProduction = mode === 'production'; + + return { + plugins: [react()], + build: { + sourcemap: isProduction ? false : 'eval-cheap-module-source-map', + lib: { + entry: path.resolve(__dirname, 'src/index.ts'), + name: 'AsgardeoAuth', + fileName: 'main', + formats: ['umd'] + }, + rollupOptions: { + external: ['react', 'react-dom', 'react-router-dom'], + output: { + globals: { + react: 'React', + 'react-dom': 'ReactDOM', + 'react-router-dom': 'ReactRouter' + } + } + } + }, + resolve: { + alias: { + '@': path.resolve(__dirname, './src') + }, + extensions: ['.tsx', '.ts', '.jsx', '.js'] + }, + esbuild: { + jsxInject: `import React from 'react'` // Optional: If you use JSX without importing React + }, + server: { + strictPort: true, + port: 3000 + } + }; +});