- Created vite.standalone.config.js for optimized bundle building - Added build scripts for standalone bundle generation - Generated three formats: IIFE (28KB), UMD (28KB), ES Module (61KB) - Includes all dependencies: qrcode and imagetracer - Added comprehensive documentation and examples - Created build script with detailed bundle information - Added terser for minification optimization - Fixed package.json dependencies and scripts
38 lines
996 B
JavaScript
38 lines
996 B
JavaScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import { resolve } from 'path'
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
build: {
|
|
// Create standalone bundle for qrCodeUtils with dependencies
|
|
lib: {
|
|
entry: resolve(__dirname, 'src/utils/qrCodeUtils.js'),
|
|
name: 'QRCodeUtils',
|
|
formats: ['es', 'umd', 'iife'],
|
|
fileName: (format) => `qr-code-utils.${format}.js`
|
|
},
|
|
rollupOptions: {
|
|
// Include all dependencies in the bundle
|
|
external: [],
|
|
output: {
|
|
// Global variable name for UMD/IIFE
|
|
globals: {},
|
|
// Bundle all dependencies
|
|
inlineDynamicImports: true
|
|
}
|
|
},
|
|
// Optimize the bundle
|
|
minify: 'terser',
|
|
sourcemap: true,
|
|
// Ensure all dependencies are included
|
|
commonjsOptions: {
|
|
include: [/node_modules/]
|
|
}
|
|
},
|
|
// Optimize dependencies
|
|
optimizeDeps: {
|
|
include: ['qrcode', 'imagetracer']
|
|
}
|
|
})
|