- In my previous post we have learnt about precompilation of Riot.js custom tags in terminal and used the generated code for rendering in browser.
- In this demo, “We will learn to use Riot.js watcher for listening to code changes in tag definition and generate the compiled code”.
- In my previous post we have already installed the Riot.js compiler globally using npm install riot –g command in terminal.So we don’t need any other installation for Riot.js watcher.
- For this demo we have used the previous post code where we have dev and out 2 directories.The dev directory contains the tag definition while the out directory contains the compiled code.The following screenshot shows the directory structure.
- The Riot.js watcher can be started using riot –w dev/my-name.tag out/my-name-tag.js command in the terminal.The following screenshot shows the terminal with riot watcher in execution.
- Now if we do nay changes in the tag definition dev/my-name.tag file, the watcher will pick the changes and compile it and updates the out/my-name-tag.js file.The following screenshot shows the log messages printed in the terminal console.