36 lines
819 B
TypeScript
36 lines
819 B
TypeScript
import { defineConfig } from 'vite'
|
|
import preact from '@preact/preset-vite'
|
|
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
|
|
import path from 'path'
|
|
import topLevelAwait from 'vite-plugin-top-level-await'
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
preact(),
|
|
topLevelAwait({
|
|
promiseExportName: '__tla',
|
|
promiseImportName: (i) => `__tla_${i}`,
|
|
}),
|
|
],
|
|
assetsInclude: ['**/*.md'],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
optimizeDeps: {
|
|
esbuildOptions: {
|
|
// Node.js global to browser globalThis
|
|
define: {
|
|
global: 'globalThis',
|
|
},
|
|
// Enable esbuild polyfill plugins
|
|
plugins: [
|
|
NodeGlobalsPolyfillPlugin({
|
|
buffer: true,
|
|
}),
|
|
],
|
|
},
|
|
},
|
|
})
|