generated from unplugin/unplugin-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathvite.config.full.ts
46 lines (42 loc) · 1.28 KB
/
vite.config.full.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import path from 'node:path'
import fs from 'node:fs'
import { createResolver } from '@nuxt/kit'
import { defineConfig } from 'vite'
import Pinceau from '../../integrations/pinceau/src/plugin'
import { getPinceauContext } from '../../packages/core/src/utils'
import { createReactPlugin } from '../../integrations/react/src/utils'
import { createVuePlugin } from '../../integrations/vue/src/utils'
import { createSveltePlugin } from '../../integrations/svelte/src/utils'
import type { PinceauContext } from '../../packages/core/src'
let ctx: PinceauContext
const { resolve } = createResolver(import.meta.url)
export default defineConfig({
plugins: [
Pinceau({
debug: 2,
dev: false,
theme: {
buildDir: path.join(__dirname, '../outputs/'),
},
}),
{
name: 'post',
configResolved(config) {
ctx = getPinceauContext(config)
},
buildEnd() {
const plugins = {
'react-plugin.js': createReactPlugin(ctx),
'vue-plugin.js': createVuePlugin(ctx),
'svelte-plugin.js': createSveltePlugin(ctx),
}
for (const [plugin, file] of Object.entries(plugins)) {
fs.writeFileSync(
resolve(`./output/${plugin}`),
file,
)
}
},
},
],
})