Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

272
Visualizações
Angular 2 building single modules

I know how to build out my project with Angular CLI: ng build --prod

How can I compile each module separately? This is my project:

Image

AnagAccreditamento and cruscottofiliera are separate modules, with their module.ts, routing.module.ts file. How I can build them separately and insert them into my project at a later time as if they were libraries?

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Not sure about angular2 but you 'could'(!) definitely do this with angular 10. Not sure if it's the right way to do it (or if further separation would be a good idea).

To achieve building multiple modules out of a single project:

  1. You obviously need multiple modules. So not only app.module.tsbut another one that contains similar model configuration stuff, i.e. called app-extension.module.ts.

  2. Accordingly you'll need another main.ts file, referencing the module. I.e. called main-extension.ts. You import the specific module there and bootstrap it.

  3. Same for tsconfig.app.json -> tsconfig.app-extension.json

  4. Next, in your angular.json file, you can extend the project -> architect -> build section by adding something like this:

       "configurations": {
         "extension": {
           "main": "src/main-extension.ts",
           "tsConfig": "tsconfig.app-extension.json",
           "outputPath": "../resources/public/extension"
         }
    
  5. finally within your package.json you add a new script

         "build:extension": "ng build && ng build --output-hashing none --configuration extension "
    

    the --output-hashing none is not really relevant here. I did this for building a custom elements-module / webcomponents for standalone use, so that's why i left it in here. Next step would be to concatenate. A better alternative probably is to use https://github.com/manfredsteyer/ngx-build-plus#readme for that purpose..

to build simply execute npm run build:extension

about 4 years ago · Santiago Trujillo Relatório

0

If you want to be able to pull in modules as they are needed, you want lazy loading. You can find out how to use lazy loading here: https://angular.io/docs/ts/latest/guide/router.html#!#asynchronous-routing

Or there is a Pluralsight course about it here: https://app.pluralsight.com/library/courses/angular-routing/table-of-contents

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda