在nextjs项目中的amplify上运行Storybook

csga3l58  于 2023-01-17  发布在  其他
关注(0)|答案(1)|浏览(155)

我试图在一个Nextjs项目中运行Amplify中的Storybook,它将框架设置为Nextjs SSR,但我继续将其更改为React,应用程序平台保持与Web计算相同
我将amplify.yaml文件更新为:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - nvm install
        - nvm use
        - yarn install --immutable
    build:
      commands:
        - npm run build-storybook
  artifacts:
    baseDirectory: storybook-static
    files:
      - "**/*"
  cache:
    paths:
      - node_modules/**/*

但构建总是失败,并出现此错误

2023-02-15T09:45:08.672Z [WARNING]: info
2023-02-15T09:45:08.672Z [WARNING]: => Output directory: /codebuild/output/src160065809/src/dc-extension-get-started/storybook-static
2023-02-15T09:45:08.737Z [INFO]: # Completed phase: build
2023-02-15T09:45:08.739Z [INFO]: ## Build completed successfully
2023-02-15T09:45:08.740Z [INFO]: # Starting caching...
2023-02-15T09:45:08.750Z [INFO]: # Creating cache artifact...
2023-02-15T09:45:21.174Z [INFO]: # Created cache artifact
2023-02-15T09:45:21.296Z [INFO]: # Uploading cache artifact...
2023-02-15T09:45:24.843Z [INFO]: # Uploaded cache artifact
2023-02-15T09:45:24.919Z [INFO]: # Caching completed
2023-02-15T09:45:24.922Z [INFO]: Setting NEXT_PRIVATE_STANDALONE=true to produce .next/standalone directory
2023-02-15T09:45:24.926Z [INFO]: # No custom headers found.
2023-02-15T09:45:24.930Z [ERROR]: !!! CustomerError: Standalone directory not found in /codebuild/output/src160065809/src/dc-extension-get-started/storybook-static/standalone. Please enable output standalone on your next.config.js file or set NEXT_PRIVATE_STANDALONE=true. https://nextjs.org/docs/advanced-features/output-file-tracing#automatically-copying-traced-files
2023-02-15T09:45:24.930Z [INFO]: # Starting environment caching...
2023-02-15T09:45:24.930Z [INFO]: # Uploading environment cache artifact...
2023-02-15T09:45:24.982Z [INFO]: # Uploaded environment cache artifact
2023-02-15T09:45:24.982Z [INFO]: # Environment caching completed
Terminating logging...

看起来它仍然试图找到一个nextjs应用程序,如何让故事书在amplify上的nextjs应用程序中运行?

mspsb9vt

mspsb9vt1#

我发现解决这个问题的方法是将Amplify分支的框架从“Next. js-SSR”更改为“Next. js-SSG". Here is where I found the guide on doing it.
希望下面的内容不会指导你做一些不推荐的事情,但是为了设置CLI(如果你还没有),我必须创建一个有一些特权的IAM用户。因为我很匆忙,我附加了Amplify管理员访问权限。你可能需要比这更小心。
然后amplify停止在./storybook-static中搜索一个独立的目录,构建过程如期完成,页面也部署完毕。

相关问题