// filename - nuxt.config.ts
import tsconfigPaths from 'vite-tsconfig-paths'
import { nodePolyfills } from '@bangjelkoski/vite-plugin-node-polyfills'
export default defineNuxtConfig({
ssr: false, // 是否预渲染你的应用
modules: [
// nuxtjs 模块
'@pinia/nuxt',
'@vueuse/nuxt',
],
typescript: {
typeCheck: 'build', // 我们建议使用 build,这样你只在构建时进行 typescript 检查
},
imports: {
// 自动导入 store 定义(如果你使用 pinia)
dirs: ['store/**'],
},
pinia: {
// 导入 pinia 定义
autoImports: ['defineStore'],
},
plugins: [
{
// 导入我们创建的 buffer 插件
src: './plugins/buffer.client.ts',
ssr: false,
},
],
// 我们只为客户端生成 sitemap,因为我们不需要服务器
// 注意:Vite + Nuxt3 的 sitemap 存在问题
// 通常生成 sitemap 需要太多时间/内存
// 构建过程可能会在 Github Actions/Netlify/Vercel 等上失败
// 所以我们必须使用另一种策略,如在本地生成它们并推送到
// busgnag 等服务
sourcemap: {
server: false,
client: true,
},
// Vite 相关配置
vite: {
plugins: [
// 设置 node + crypto polyfill + vite TS 路径解析
tsconfigPaths(),
nodePolyfills({ protocolImports: false }),
],
build: {
sourcemap: false, // 我们不生成
// 默认 rollup 选项
rollupOptions: {
cache: false,
output: {
manualChunks: (id: string) => {
//
},
},
},
},
// @bangjelkoski/vite-plugin-node-polyfills 插件的
// 某些 Vite 相关问题需要此配置
optimizeDeps: {
exclude: ['fsevents'],
},
},
})