O
O
Oleg Drapeza2016-09-08 19:22:15
JavaScript
Oleg Drapeza, 2016-09-08 19:22:15

How to specify a dynamic path in require when building Webpack?

Good evening!
I'm trying to build a project through Webpack, using the CommonsChunkPlugin plugin to split the code into separate bundles.
Initially, the project was made under Require js, in some places the path is selected dynamically:

promise.then(function(alias) {
    require([alias], function() {
        // ...
    });
});

Webpack rightly swears 'request of a dependency is an expression'.
The question is, is there a specific recipe for using dynamic paths, or do I need to change the structure of the code by calling static paths?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lemme, 2016-09-08
@SuperOleg39ru

require.ensure
webpack.github.io/docs/context.html
For video lovers https://www.youtube.com/watch?v=BE-MXZLDwN4

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question