Critical dependencies - the request of a dependency is an expression Webpack

后端 未结 1 538
长发绾君心
长发绾君心 2020-12-09 17:27

I am using a service in my angular application to create uibModal as follows

function modal(modalConfig){
                  var mod         


        
相关标签:
1条回答
  • 2020-12-09 18:13

    After much hit and trial found the solution.What i did is this:

    template: require("../../scripts" + modalConfig.templateUrl + ".html")
    

    Assumptions

    1. root folder under which all the file comes is scripts
    2. and the relative path of this folder from the file in which the function is written is say ../../scripts.
    3. ../../scripts + modalConfig.templateUrl + ".html" will form the correct path for the file to be used.

    Mandatory Note

    1. Always write some hardcoded path of root folder. Don't put it in variable. so this won't work

      var context = "../../scripts" ; template: require(context + modalConfig.templateUrl + ".html")

    The base path (as in a part of the actual path) has to be hardcoded for basic reference, as in it helps webpack to create a list of all the modules which might be needed for the dynamic requires.

    Reason (from webpack docs) , read dynamic requires.

    0 讨论(0)
提交回复
热议问题