Dominick Piganell
Dominick Piganell

Reputation: 724

Angular 2 CLI Bundle per component

I'm wondering if it is possible to split up bundles using the angular cli based on a component. For instance, I would like to have multiple components in this app that could or could not exist on the same page, but reference them through separate bundles. Some kind of set up like this would be desired:

/test-app
    .angular-cli.json
    package.json
    tslint.json
    src
        app
            email-list
                    *.ts
                    *.html
            email-compose
                    *.ts
                    *.html
            links-links
                    *.ts
                    *.html

After the project is built, I would like to be able to have the following bundles:

poylfills.bundle.js
vendor.bundle.js
email.bundle.js
links.bundle.js

Is this possible?

Upvotes: 0

Views: 221

Answers (1)

Nikolaj Dam Larsen
Nikolaj Dam Larsen

Reputation: 5694

They've prepared support for multiple apps/entry-points (which is equivalent to what you're asking) in the angular-cli.json, but they havn't gotten around to implement it yet. Here's a link to the issues page

In addition, they've announced that they don't intent to expose the webpack configuration of angular-cli, so you wont be able to use your own custom webpack config to do the separate bundling.

So for now, I guess the conclusion is, that it may not be possible (or worth the effort) to make Angular-cli create multiple separate bundles. So you'll probably have to either wait, or skip using the cli, and do the bundling "manually" (create your own bundling process using grunt, gulp, webpack or similar).

Upvotes: 1

Related Questions