Files
superwork/vscode/webview-ui/vite.config.ts
T
cruldra af56985d9a ✨ feat(vscode): 代码阅读预览界面
Vite 加 code-reader.html 第二入口;代码块树(层级竖线、折叠、种类标签配色)、译文 / 源码按词性着色、块内直接编辑(防抖回写整行、Esc 回预览)、翻译下拉、解析失败提示;看板与代码阅读共用带类型的 acquireVsCodeApi 包装和 ErrorBoundary。
2026-09-24 21:01:34 +08:00

35 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import path from 'node:path'
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [react(), tailwindcss()],
base: './',
build: {
outDir: '../dist/webview-ui',
emptyOutDir: true,
// webview 的 CSP 只放行带 nonce 的 <script>,Vite 注入的 modulepreload <link> 会被拦下报错;
// 本地资源预加载也没有收益。入口脚本 import 的共享块会继承 nonce,照常加载。
modulePreload: false,
rollupOptions: {
// 两个 webview 页面:看板(index.html)和代码阅读预览(code-reader.html)
input: {
'index': path.resolve(__dirname, 'index.html'),
'code-reader': path.resolve(__dirname, 'code-reader.html'),
},
output: {
entryFileNames: 'assets/[name].js',
// 入口由加载方按 mtime 加 ?v= 防缓存,入口 import 的共享块(React 等)没有这一步,只能靠文件名带内容哈希
chunkFileNames: 'assets/[name]-[hash].js',
assetFileNames: 'assets/[name].[ext]',
},
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
})