Require externally hosted javascript and CSS files with webant
There should be no need to install this module since it's required by the webant module by default.
If for some reason you'd like to use the module outside of webant, install as follows:
$ npm install webant-handler-external
Ensure the external
handler is present in your webant configuration file.
An example configuration file which uses this handler may look like this:
{
"jsEntryPath":"%%base%%/src/js/main.js",
"jsDestPath":"%%base%%/build/main.js",
"htmlEntryPath":"%%base%%/src/index.hbs",
"htmlDestPath":"%%base%%/build/index.html",
"handlers":{
"external":{}
}
}
Note that both htmlEntryPath
and htmlDestPath
must be defined to make full use of this handler.
You may now require
CSS files via the comment style:
//=>require https://awebsite.com/path/to/styles.css
//=>require http://another.website.net/assets/popularlibrary.js
All external files require
d this way can be accessed in the handlebars file at htmlEntryPath
as follows:
<!DOCTYPE html>
<html>
<head>
{{#each externalCss}}<link rel="stylesheet" type="text/css" href="{{{this}}}" />{{/each}}
{{#each externalJs}}<script type="text/javascript" src="{{{this}}}"></script>{{/each}}
</head>
<body></body>
</html>
See the webant module for more information.
$ npm test