|
| 1 | +import path from 'node:path' |
1 | 2 | import { defineConfig } from 'vite'
|
2 |
| -import { server } from '@stacksjs/server' |
3 |
| -import { cssEngine, uiEngine } from './' |
| 3 | +import Vue from '@vitejs/plugin-vue' |
| 4 | +import Pages from 'vite-plugin-pages' |
| 5 | +import generateSitemap from 'vite-ssg-sitemap' |
| 6 | +import Components from 'unplugin-vue-components/vite' |
| 7 | +import AutoImport from 'unplugin-auto-import/vite' |
| 8 | +import Markdown from 'vite-plugin-vue-markdown' |
| 9 | +import { VitePWA } from 'vite-plugin-pwa' |
| 10 | +import Inspect from 'vite-plugin-inspect' |
| 11 | +import LinkAttributes from 'markdown-it-link-attributes' |
| 12 | +import Unocss from '@unocss/vite' |
| 13 | +import Shiki from 'markdown-it-shiki' |
4 | 14 |
|
5 | 15 | export default defineConfig({
|
| 16 | + resolve: { |
| 17 | + alias: { |
| 18 | + '~/': `${path.resolve(__dirname, '../../../../')}/`, |
| 19 | + }, |
| 20 | + }, |
6 | 21 | clearScreen: false,
|
7 | 22 |
|
8 |
| - server, |
| 23 | + server: { |
| 24 | + port: 3333, |
| 25 | + strictPort: true, |
| 26 | + }, |
| 27 | + envPrefix: ['VITE_', 'TAURI_'], |
| 28 | + plugins: [ |
9 | 29 |
|
10 |
| - envPrefix: 'APP_', |
| 30 | + Vue({ |
| 31 | + include: [/\.vue$/, /\.md$/], |
| 32 | + reactivityTransform: true, |
| 33 | + }), |
| 34 | + |
| 35 | + // https://github.com/hannoeru/vite-plugin-pages |
| 36 | + Pages({ |
| 37 | + extensions: ['vue', 'md'], |
| 38 | + }), |
| 39 | + |
| 40 | + // https://github.com/antfu/unplugin-auto-import |
| 41 | + AutoImport({ |
| 42 | + imports: [ |
| 43 | + 'vue', |
| 44 | + 'vue-router', |
| 45 | + 'vue-i18n', |
| 46 | + 'vue/macros', |
| 47 | + '@vueuse/head', |
| 48 | + '@vueuse/core', |
| 49 | + ], |
| 50 | + dts: '../../../auto-imports.d.ts', |
| 51 | + dirs: [ |
| 52 | + '../../../../functions', |
| 53 | + '../../../../app/stores', |
| 54 | + ], |
| 55 | + vueTemplate: true, |
| 56 | + }), |
| 57 | + |
| 58 | + // https://github.com/antfu/unplugin-vue-components |
| 59 | + Components({ |
| 60 | + // allow auto load markdown components under `./src/components/` |
| 61 | + extensions: ['vue', 'md'], |
| 62 | + // allow auto import and register components used in markdown |
| 63 | + include: [/\.vue$/, /\.vue\?vue/, /\.md$/], |
| 64 | + dts: '../../../../components', |
| 65 | + }), |
| 66 | + |
| 67 | + // https://github.com/antfu/unocss |
| 68 | + // see unocss.config.ts for config |
| 69 | + Unocss({ |
| 70 | + configFile: '../../ui/src/unocss.config.ts', |
| 71 | + mode: 'vue-scoped', |
| 72 | + }), |
| 73 | + |
| 74 | + // https://github.com/antfu/vite-plugin-vue-markdown |
| 75 | + // Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite |
| 76 | + Markdown({ |
| 77 | + wrapperClasses: 'prose prose-sm m-auto text-left', |
| 78 | + headEnabled: true, |
| 79 | + markdownItSetup(md) { |
| 80 | + // https://prismjs.com/ |
| 81 | + md.use(Shiki, { |
| 82 | + theme: { |
| 83 | + light: 'vitesse-light', |
| 84 | + dark: 'vitesse-dark', |
| 85 | + }, |
| 86 | + }) |
| 87 | + md.use(LinkAttributes, { |
| 88 | + matcher: (link: string) => /^https?:\/\//.test(link), |
| 89 | + attrs: { |
| 90 | + target: '_blank', |
| 91 | + rel: 'noopener', |
| 92 | + }, |
| 93 | + }) |
| 94 | + }, |
| 95 | + }), |
| 96 | + |
| 97 | + // https://github.com/antfu/vite-plugin-pwa |
| 98 | + VitePWA({ |
| 99 | + registerType: 'autoUpdate', |
| 100 | + includeAssets: ['favicon.ico', 'safari-pinned-tab.svg'], |
| 101 | + manifest: { |
| 102 | + name: 'Vitesse', |
| 103 | + short_name: 'Vitesse', |
| 104 | + theme_color: '#ffffff', |
| 105 | + icons: [ |
| 106 | + { |
| 107 | + src: '/pwa-192x192.png', |
| 108 | + sizes: '192x192', |
| 109 | + type: 'image/png', |
| 110 | + }, |
| 111 | + { |
| 112 | + src: '/pwa-512x512.png', |
| 113 | + sizes: '512x512', |
| 114 | + type: 'image/png', |
| 115 | + }, |
| 116 | + { |
| 117 | + src: '/pwa-512x512.png', |
| 118 | + sizes: '512x512', |
| 119 | + type: 'image/png', |
| 120 | + purpose: 'any maskable', |
| 121 | + }, |
| 122 | + ], |
| 123 | + }, |
| 124 | + }), |
| 125 | + |
| 126 | + // https://github.com/antfu/vite-plugin-inspect |
| 127 | + // Visit http://localhost:3333/__inspect/ to see the inspector |
| 128 | + Inspect(), |
11 | 129 |
|
12 |
| - plugins: [ |
13 |
| - uiEngine(), |
14 |
| - cssEngine(), |
15 | 130 | ],
|
16 | 131 |
|
17 |
| - build: { |
18 |
| - target: ['es2021', 'chrome97', 'safari13'], |
19 |
| - minify: !process.env.APP_DEBUG ? 'esbuild' : false, |
20 |
| - sourcemap: !!process.env.APP_DEBUG, |
| 132 | + // https://github.com/vitest-dev/vitest |
| 133 | + test: { |
| 134 | + include: ['test/**/*.test.ts'], |
| 135 | + environment: 'jsdom', |
| 136 | + deps: { |
| 137 | + inline: ['@vue', '@vueuse', 'vue-demi'], |
| 138 | + }, |
| 139 | + }, |
| 140 | + |
| 141 | + // https://github.com/antfu/vite-ssg |
| 142 | + ssgOptions: { |
| 143 | + script: 'async', |
| 144 | + formatting: 'minify', |
| 145 | + onFinished() { generateSitemap() }, |
| 146 | + }, |
| 147 | + |
| 148 | + ssr: { |
| 149 | + // TODO: workaround until they support native ESM |
| 150 | + noExternal: ['workbox-window', /vue-i18n/], |
21 | 151 | },
|
22 | 152 | })
|
0 commit comments