有一个在 nx 和 next 13 中共享的资产库。

huangapple go评论58阅读模式
英文:

Have a shared library for assets in nx and next 13

问题

我想在我的nx monorepo中为资产创建一个共享库,我们在两个项目中都使用了next.js。

我阅读了文档,您可以使用以下方式:

"assets": [
  {
    "input": "libs/my-lib/public",
    "glob": "**/*",
    "output": "./.."
  }
],

但出于某种原因,它不起作用。当我像这样导入图像时,它会显示404错误。不确定这是否也是正确的方式。

英文:

I want to have a shared library for assets in my nx monorepo we are both using next js in both projects.

I read the docs that you can use:

    "assets": [
      {
        "input": "libs/my-lib/public",
        "glob": "**/*",
        "output": "./.."
      }
    ],

But for some reason it just doesn't work. It states a 404 for my images when I import them like this. Not sure if this is also the way to go though.

答案1

得分: 0

在 project.json 中添加这行代码后,只需运行 npm run build,nx 就会立即复制并粘贴您的图片。

英文:

It seems if you add this in project.json you just need to do an npm run build and nx would copy and paste your images immediately.

huangapple
  • 本文由 发表于 2023年6月8日 14:33:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76429163.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定