- 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
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
import { defineConfig } from 'vite'
|
|
import { resolve } from 'path'
|
|
|
|
// Standalone bundle configuration for qrCodeUtils
|
|
export default defineConfig({
|
|
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 chunk splitting
|
|
manualChunks: undefined
|
|
}
|
|
},
|
|
// Optimize the bundle
|
|
minify: 'terser',
|
|
sourcemap: true,
|
|
// Ensure all dependencies are included
|
|
commonjsOptions: {
|
|
include: [/node_modules/]
|
|
},
|
|
// Target modern browsers for smaller bundle
|
|
target: 'es2018'
|
|
},
|
|
// Optimize dependencies
|
|
optimizeDeps: {
|
|
include: ['qrcode', 'imagetracer']
|
|
},
|
|
// Define environment
|
|
define: {
|
|
'process.env.NODE_ENV': '"production"'
|
|
}
|
|
})
|