Skip to content

A node module for requiring externally hosted javascript and CSS files with webant

License

Notifications You must be signed in to change notification settings

theakman2/node-modules-webant-handler-external

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-modules-webant-handler-external

Require externally hosted javascript and CSS files with webant

Installation

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

Usage

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 required 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.

Tests

$ npm test

About

A node module for requiring externally hosted javascript and CSS files with webant

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published