是否可以按需构建模块?

时间:2019-05-13 15:57:20

标签: angular webpack angular-cli

我想按需构建有角度的应用程序模块,这样我就可以根据需要为应用程序A构建一些模块,并为应用程序B构建其他模块,因为应用程序A和B具有一些通用模块,但由于不同的业务功能。所有模块都在同一个角度项目中。

这是针对基于角度的可配置前端产品,我们可以通过配置文件来决定需要构建哪个模块,而不需要构建哪个模块。 我现在正在尝试使用webpack而不是angular-cli进行此操作,我相信如果webpack.config.js可以正常工作,那么angular-cli也可以。

我的角度项目建立在ng-alain上,项目结构如下:

0:000> !u 000007fe`9abcdef0

Normal JIT generated code
DynamicClass.Add(Int32, Int32)
Begin 000007fe9abcdef0, size 4
>>> 000007fe`9abcdef0 8d0411          lea     eax,[rcx+rdx]
000007fe`9abcdef3 c3              ret

父模块是:

--src
  |_app
    |_routes
      |_callback
      |_dashboard
      |_test1
        |_test1.module.ts
        |_test1-routing.module.ts
      |_test2
        |_test2.module.ts
        |_test2-routing.module.ts
      |_test3
        |_test3.module.ts
        |_test3-routing.module.ts
      |_test4
        |_test4.module.ts
        |_test4-routing.module.ts
      |_routes.module.ts
      |_routes-routing.module.ts

常用模块是:

|_routes
  |_routes.module.ts
  |_routes-routing.module.ts

如果应用A需要通用模块以及test1,test2,test3,那么我需要使用以下模块来构建应用A:

|_routes
    |_callback
    |_dashboard
    |_test1
      |_test1.module.ts
      |_test1-routing.module.ts
    |_test2
      |_test2.module.ts
      |_test2-routing.module.ts

和应用B需要通用的模块以及test1,test2,test4,因此我需要使用以下模块来构建应用B:

|_routes
    |_callback
    |_dashboard
    |_test1
      |_test1.module.ts
      |_test1-routing.module.ts
    |_test2
      |_test2.module.ts
      |_test2-routing.module.ts
    |_test3
      |_test3.module.ts
      |_test3-routing.module.ts

我查看了一些相关信息,发现micro app,我认为这不是解决方案,对于一个简单的应用程序来说,它很复杂。 Webpack中是否有插件或其他方法可以帮助我做到这一点?

0 个答案:

没有答案
相关问题