Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create vite.config.js #256

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions lib/vite.config.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add this to the sample react apps in /samples directory to make this work. Were you able to verify the changes in your local setup?

Original file line number Diff line number Diff line change
@@ -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
}
};
});