如何通过Redux使用本地库部署Angular App

时间:2019-02-14 23:18:01

标签: angular angular-redux

我们正在开发一个角度库,并将其发布到私人仓库中。我们运行一个本地Web应用程序来测试开发中的库。我们还出版了图书馆。

当我使用ng build构建应用程序时,结果dist版本无法运行。

我的文件结构是:

./projects/my-library
./src

我的CI构建过程为:

npm ci
npm run build // Creates dist/my-library
ng build --base-href '/test' --configuration=test --output-path=./dist/test

我最终得到一个dist目录:

./dist/my-library
./dist/test

index.html中的./dist/test文件是

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Another App</title>
    <base href="/test" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="icon" type="image/x-icon" href="favicon.ico" />
    <link rel="stylesheet" href="styles.2bf96ac9aaebbaa03e0c.css" />
  </head>

  <body>
    <app-root></app-root>
    <script type="text/javascript" src="runtime.17ac16aaa641f7087ac1.js"></script>
    <script type="text/javascript" src="polyfills.d1c7bf4a2ae7c3435f95.js"></script>
    <script type="text/javascript" src="main.08b6c456c92aa092bef8.js"></script>
  </body>
</html>

为确保此方法有效,我正在运行http-server来测试我的应用程序:

http-server ./dist/test

这是我的问题。该应用程序正在询问我是否忘记配置商店?我不明白,因为这只会在我运行应用程序的dist版本时发生。

这是错误:

ERROR Error: Uncaught (in promise): Error: Dispatch failed: did you forget to configure your store? https://github.com/angular-redux/@angular-redux/core/blob/master/README.md#quick-start
Error: Dispatch failed: did you forget to configure your store? https://github.com/angular-redux/@angular-redux/core/blob/master/README.md#quick-start
    at Object.e.assert (4.131ee1951f9b1e86a9da.js:1)
    at e.n.dispatch (4.131ee1951f9b1e86a9da.js:1)
    at new <anonymous> (4.131ee1951f9b1e86a9da.js:1)
    at main.08b6c456c92aa092bef8.js:1
    at Wd (main.08b6c456c92aa092bef8.js:1)
    at main.08b6c456c92aa092bef8.js:1
    at new t (main.08b6c456c92aa092bef8.js:1)
    at gh (main.08b6c456c92aa092bef8.js:1)
    at Object.Ay [as createNgModuleRef] (main.08b6c456c92aa092bef8.js:1)
    at e.create (main.08b6c456c92aa092bef8.js:1)
    at O (polyfills.d1c7bf4a2ae7c3435f95.js:1)
    at O (polyfills.d1c7bf4a2ae7c3435f95.js:1)
    at polyfills.d1c7bf4a2ae7c3435f95.js:1
    at e.invokeTask (polyfills.d1c7bf4a2ae7c3435f95.js:1)
    at Object.onInvokeTask (main.08b6c456c92aa092bef8.js:1)
    at e.invokeTask (polyfills.d1c7bf4a2ae7c3435f95.js:1)
    at t.runTask (polyfills.d1c7bf4a2ae7c3435f95.js:1)
    at v (polyfills.d1c7bf4a2ae7c3435f95.js:1)

肯定是@angular-redux/store导致了此问题。我删除了目录dist/my-library,但遇到相同的错误。 Angular可以使用本地库来构建应用程序,但是本地库因Redux存储(@angular-redux/store)而失败。

0 个答案:

没有答案