简体   繁体   中英

Gulp require html in javascript file like webpack

There is a way to require html file in javascript file like webpack does with gulp ?

For example in Angular js directive:

return {
  template: require('./../index.html),
  link : function() {}
}

No, angularjs is a client-side framework that is meant to run in a browser. Within a browser you generally speaking are not meant to be reading local files even if the purpose is just for including/requiring files.

Webpack is actually a node module (npm) that runs under nodejs. The require method is added by nodejs and allows you to load other javascript files. However, nodejs modules are always run by nodejs and never in the browser.

Having said that, there might be solutions to achieve what you want, here is one discussion of a similar issue .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM