1

I am working on an Angular2 application with large no of separate modules. The module specific files(js,css,html) are fetched only when module is created dynamically (...using moduleFactory and createComponent).

So I need to bundle my app in such a way that instead of having single bundle.js, I want each module as a separate chunk so that the chunk(js) is only fetched when the module is created.

how can I achieve this in angular cli ?? will CommonsChunkPlugin be helpful?

1 Answer 1

1

You can setup your project with webpack directly without using angular-cli and use require.ensure() to include external file dynamically. Webpack will detect require.ensure() and will create a separate chunk for it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.