This article sheds light on referring external to your root recipe & tool files (page-loop.js, scrape.js and tool.js) file dependencies.
Since 1.2 recipes and tools can produce results having an html preview.
In this html you can load images, scripts or styles. You should always consider the root of your recipe/tool as a root in the html.
For example in this recipe structure:
If your template.html wants to load the logo.png file, it can refer to it like this:
Or loading NodeJS modules which aren’t published on the NPM. These are simply referred to as with any regular NodeJS project.
Your tool/recipe isn't a regular NodeJS package - it should be browserifiable!
Here is an example of loading a utils.js package located in a ‘src’ dir placed in the root of a recipe:
var utils = require("./src/utils");
Both page-loop.js and scrape.js are able to load the package this way.
You can load templates or other textual resources in your recipes and tools, using the fs module’s readFileSync (available starting from Pagehop 1.2).
At compile time, calls to readFileSync are replaced with the actual content of the files (you can check the brfs npm module for more info).
Don't use comma separated statements for require fs, path and for loading resources with readFileSync!
Here is an example which will work fine:
var path = require('path');
This will NOT work:
var path = require('path'),
Don't minify/uglify recipes and tools which use fs
Don't import through ES6 syntax