34 lines
847 B
TypeScript
34 lines
847 B
TypeScript
|
|
import { resolve } from 'path'
|
||
|
|
import react from '@vitejs/plugin-react'
|
||
|
|
import { defineConfig } from 'vite'
|
||
|
|
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
|
||
|
|
|
||
|
|
export default defineConfig(({ mode }) => ({
|
||
|
|
plugins: [react(), cssInjectedByJsPlugin()],
|
||
|
|
build: {
|
||
|
|
lib: {
|
||
|
|
entry: resolve(__dirname, 'src/index.tsx'),
|
||
|
|
name: '__LIB_GLOBAL_NAME__',
|
||
|
|
fileName: '__BUNDLE_NAME__',
|
||
|
|
formats: ['es']
|
||
|
|
},
|
||
|
|
rollupOptions: {
|
||
|
|
external: ['react', 'react-dom', 'react/jsx-runtime'],
|
||
|
|
output: {
|
||
|
|
globals: {
|
||
|
|
react: 'React',
|
||
|
|
'react-dom': 'ReactDOM',
|
||
|
|
'react/jsx-runtime': 'jsxRuntime'
|
||
|
|
},
|
||
|
|
assetFileNames: 'assets/[name][extname]'
|
||
|
|
}
|
||
|
|
},
|
||
|
|
sourcemap: true,
|
||
|
|
minify: mode === 'production'
|
||
|
|
},
|
||
|
|
server: {
|
||
|
|
port: 3001,
|
||
|
|
open: true
|
||
|
|
}
|
||
|
|
}))
|