There are also 2 extra methods specifically for uki: requireCss and
requireText.
- requireText will directly embed content of a file into the code as a
string. It works with templates. Instead of loading template from a server
with a separate request it's often much easier to embed the template
directly into the JS file. It will generally be faster to load. So
requireText does just that. When you do
Mustache.to_html(requireText('my.html'), {}) it will be expanded into
Mustache.to_html('<code>{{{value}}}</code>', {});
- requireCss will embed css code into js. It will also minimize css
(remove spaces) and embed images using data:uri. You can then access
imported css all as one chunk using __requiredCss variable.
Both of this methods allow to put all resources related to a single view
in one place. It also simplifies deployment (single js file instead of
several folders) and loading speeds.
All of the code responsible for that is in tools/static_require.js
Hope that helps
node.js itself does not modify your client files. static_require does.
Once you load something as src/uki.js node.js server will process this
file using static_require handler. static_require will process require(),
requireText() and requireCss() calls. You can add ?squeeze=1 to the path
(src/uki.js?squeeze=1) to get a single line, compressed production version.