繁体   English   中英

Nuxt3 模块不包含在构建中

[英]Nuxt3 modules are not included in build

我有nuxt3js项目(版本:v3.0.0-rc.3)。 对于其他服务器端功能,例如 WebSocket 服务器; 身份验证检查; 数据库连接; ...,我创建了一个包含所有这些附加逻辑的模块文件夹。

📦project
┣ 📂modules
┃ ┣ 📂auth
┃ ┃ ┣ 📜index.ts
┃ ┃ ┗ 📜...
┃ ┗ 📂websocket
┃ ┃ ┗ 📜index.ts
┃ ┗ 📂...
┃   ┗ 📜...
┣ ...
┣ 📜nuxt.config.ts
┃ 
┗ ...

然后在nuxt.config.ts我像这样添加了它们:

// nuxt.config.ts
import { defineNuxtConfig } from "nuxt";

export default defineNuxtConfig({
  ...
  modules: [
    ...
    "~/modules/auth/index.ts",
    "~/modules/websocket/index.ts",
    ...
  ],
  ...
});

项目逻辑在开发时工作正常,并使用yarn dev启动一切,在一切开始之前,所有模块都按预期一一执行。 现在,当项目准备好进行首次部署时,我正在运行yarn build ,它没有错误地完成并生成以下文件夹:

📦.output
 ┣ 📂public
 ┃ ┗ 📂_nuxt
 ┃ ┃ ┗ 📜...
 ┣ 📂server
 ┃ ┣ 📂chunks
 ┃ ┃ ┗ 📜...
 ┃ ┣ 📂node_modules
 ┃ ┃ ┗ 📂...
 ┃ ┃   ┗ 📜...
 ┃ ┣ 📜index.mjs
 ┃ ┣ 📜index.mjs.map
 ┃ ┗ 📜package.json
 ┗ 📜nitro.json

现在使用提示命令node.output/server/index.mjs启动服务器成功启动了一个可从浏览器访问的服务器,唯一的问题是我的模块逻辑都不起作用,似乎yarn build不包括我的模块到最后构建。

我错过了什么?

也许请检查是否需要在 nuxt.config.js 转译部分添加任何代码/package。 例如需要添加无头用户界面和@aspida/axios

build: {
    transpile: ['@headlessui/vue', '@aspida/axios'],
}

阅读更多: https://v3.nuxtjs.org/guide/going-further/esm/#transpiling-libraries

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM