UNPKG

tonka-vite-plugin

Version:

A Vite plugin for Inertia.js that provides automatic page imports and enhanced development experience.

44 lines (43 loc) 1.51 kB
import path from 'path'; export default function tonkaPlugin(options = {}) { const root = process.cwd(); return { name: 'tonka-vite-plugin', config: (userConfig, { command }) => { const input = options.input || { 'resources/css/app.css': undefined, 'resources/js/app.tsx': undefined, }; const outDir = options.outDir || path.resolve(root, 'public/build'); const manifest = options.manifest !== false ? 'manifest.json' : false; const ssrBuild = options.ssr ? options.ssr : false; return { build: { outDir: outDir, manifest: manifest, assetsDir: options.assetsDir || 'assets', rollupOptions: { input: input, }, ssr: ssrBuild, sourcemap: command === 'serve', copyPublicDir: false, }, resolve: { alias: options.alias || { '@': path.resolve(root, '.'), }, }, optimizeDeps: { include: ['react', 'react-dom', '@inertiajs/react', 'axios'], exclude: [], }, }; }, transformIndexHtml(html) { if (options.refresh) { } return html; }, }; }