Dev
Run a local server in watch mode to serve your extension to Roam!
The RoamJS Scripts
dev
command compiles your extension and serves it locally using Webpack Dev Server. Making changes to the script while the webserver is running will be automatically compiled, so you will not need to restart the server to see new changes. You will however need to refresh Roam to view the new changes.The script is built in development mode with
NODE_ENV=development
. There are also source maps included making it easier to debug changes in the chrome console. By default, the webserver runs on port
8000
. To load your extension into Roam, create a {{[[roam/js]]}}
block and add the following as a child code block set to javascript
:var existing = document.getElementById("extension-name");
if (!existing) {
var extension = document.createElement("script");
extension.src = "http://localhost:8000/main.js";
extension.id = "extension-name";
extension.async = true;
extension.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(extension);
}
Add the following script to your
package.json
:"dev": "roamjs-scripts dev"
Then run the following command from the command line:
npm run dev
--port [number]
- The port that the webserver will be running on locally. The default value is 8000.
Last modified 2yr ago