42 行
1.4 KiB
TypeScript
42 行
1.4 KiB
TypeScript
import mdx from '@mdx-js/rollup'
|
|
import react from '@vitejs/plugin-react'
|
|
import path from 'path'
|
|
import remarkGFM from 'remark-gfm'
|
|
import { defineConfig } from 'vite'
|
|
|
|
import { helpAssets } from './scripts/help-assets'
|
|
|
|
const mdxPlugin = mdx ({ providerImportSource: '@/mdx-components',
|
|
remarkPlugins: [remarkGFM] })
|
|
const originalTransform = mdxPlugin.transform
|
|
|
|
if (typeof originalTransform === 'function')
|
|
{
|
|
mdxPlugin.transform =
|
|
function (code, id)
|
|
{
|
|
return (/[?&](raw|url)(?:&|$)/.test (id)
|
|
? Promise.resolve (undefined)
|
|
: originalTransform.call (this, code, id))
|
|
}
|
|
}
|
|
|
|
export default defineConfig ({
|
|
plugins: [{ name: 'request-render-context', enforce: 'pre',
|
|
resolveId (id, _importer, options) {
|
|
const contextPath = path.resolve (__dirname, './src/lib/renderContext')
|
|
if (options.ssr && (id === contextPath || id === `${contextPath}.ts`))
|
|
return path.resolve (__dirname, './src/lib/renderContext.server.ts')
|
|
} }, helpAssets (), mdxPlugin, react ()],
|
|
resolve: { alias: { '@': path.resolve (__dirname, './src') } },
|
|
ssr: { noExternal: ['react-helmet-async'] },
|
|
server: { host: true,
|
|
port: 5173,
|
|
strictPort: true,
|
|
allowedHosts: ['hub.nizika.monster', 'localhost', 'nico-dev.test'],
|
|
proxy: { '/api': { target: 'http://localhost:3002',
|
|
changeOrigin: true,
|
|
secure: false } },
|
|
watch: { usePolling: true,
|
|
interval: 100 } } })
|