Nuxt/packages/ui-templates/vite.config.ts

40 lines
939 B
TypeScript
Raw Normal View History

import { fileURLToPath } from 'node:url'
import { resolve } from 'node:path'
import { readdirSync } from 'node:fs'
2021-12-22 13:04:06 +00:00
import { defineConfig } from 'vite'
import UnoCSS from 'unocss/vite'
2021-12-22 13:04:06 +00:00
import { DevRenderingPlugin } from './lib/dev'
import { RenderPlugin } from './lib/render'
const rootDir = fileURLToPath(new URL('.', import.meta.url))
const r = (...path: string[]) => resolve(rootDir, ...path)
2021-12-22 13:04:06 +00:00
export default defineConfig({
build: {
outDir: process.env.OUTPUT_DIR || 'dist',
2021-12-22 13:04:06 +00:00
rollupOptions: {
input: {
...Object.fromEntries(
readdirSync(r('templates')).filter(dir => dir !== 'messages.json').map(dir => [
dir,
r('templates', dir, 'index.html'),
]),
2021-12-22 13:04:06 +00:00
),
index: r('index.html'),
},
},
2021-12-22 13:04:06 +00:00
},
plugins: [
UnoCSS(),
2021-12-22 13:04:06 +00:00
DevRenderingPlugin(),
RenderPlugin(),
2021-12-22 13:04:06 +00:00
],
server: {
fs: {
allow: ['./templates', rootDir],
},
},
2021-12-22 13:04:06 +00:00
})