Initial commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { resolve } from 'path'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import { defineConfig } from 'vite'
|
||||
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
|
||||
|
||||
// IIFE format: component registers itself in window.GlitchComponents at load time.
|
||||
// react/jsx-runtime is intentionally NOT external — it gets bundled and reads from window.React.
|
||||
// Host apps must expose window.React and window.ReactDOM before loading any component script.
|
||||
export default defineConfig(({ mode }) => ({
|
||||
plugins: [react(), cssInjectedByJsPlugin()],
|
||||
build: {
|
||||
lib: {
|
||||
entry: resolve(__dirname, 'src/index.tsx'),
|
||||
name: 'GlitchComponent',
|
||||
fileName: () => 'bloodsugar.js',
|
||||
formats: ['iife']
|
||||
},
|
||||
rollupOptions: {
|
||||
external: ['react', 'react-dom'],
|
||||
output: {
|
||||
globals: {
|
||||
react: 'React',
|
||||
'react-dom': 'ReactDOM',
|
||||
},
|
||||
assetFileNames: 'assets/[name][extname]',
|
||||
exports: 'named'
|
||||
}
|
||||
},
|
||||
sourcemap: true,
|
||||
minify: mode === 'production'
|
||||
},
|
||||
server: {
|
||||
port: 3001,
|
||||
open: true
|
||||
}
|
||||
}))
|
||||
Reference in New Issue
Block a user