webpack 为什么storybook绑定通过http请求获取angular组件模板?

8ftvxx2r  于 2023-10-19  发布在  Webpack
关注(0)|答案(1)|浏览(118)

在将angular更新到v12和将storybook更新到v6.3.13之后,有请求获取组件模板,但在storybook中没有v5.3。请求以404结尾。

环境:

"@storybook/angular/webpack": "^5"
    "@angular/cli": "^12.2.18",
    "storybook": "6.3.13",
    "typescript": "4.3.5",
    "@storybook/angular": "6.3.13",
    "@storybook/builder-webpack5": "6.3.13",
    "@storybook/manager-webpack5": "6.3.13",
    "webpack": "^5.88.2"

.storybook/main.js

module.exports = {
    staticDirs: ['../dist/ui-kit', '../src/assets'],
    stories: ['../src/**/*.stories.ts'],
    framework: {name: '@storybook/angular'},
    core: {
        builder: 'webpack5',
    },
};

angular.json build config

"ui-kit": {
  "root": "projects/ui-kit",
  "sourceRoot": "projects/ui-kit/src",
  "projectType": "library",
  "prefix": "lib",
  "architect": {
    "build": {
      "builder": "@angular-devkit/build-angular:ng-packagr",
      "options": {
        "tsConfig": "projects/evo-ui-kit/tsconfig.lib.json",
        "project": "projects/evo-ui-kit/ng-package.json"
      }
    }
  }
}
rsaldnfx

rsaldnfx1#

最后通过在angle.json中添加项目配置解决了这个问题:

{
  "projects": {
  ...
    "storybook": {
      "projectType": "application",
      "root": "stories",
      "sourceRoot": "stories",
      "architect": {
        "build": {
          "options": {
            "tsConfig": "tsconfig.json",
            "assets": []
          }
        }
      }
    }
   }
}

相关问题