Closed paulocheque closed 8 years ago
You could use browserify with the standalone option to make a bundle that you can load with a script tag in your website.
Since you also need the virtual-dom dependency, you'll have to create a new project folder and thennpm install html-to-vdom virtual-dom
.
Then you create an index.js
that looks like this
var VNode = require('virtual-dom/vnode/vnode');
var VText = require('virtual-dom/vnode/vtext');
var convertHTML = require('html-to-vdom')({
VNode: VNode,
VText: VText
});
module.exports = convertHTML;
That's the module we want to export to the browser, since it contains everything it needs to run standalone.
After that run browserify ./index.js -s convertHTML > html-to-vdom.js
. The html-to-vdom.js
contains everything that's necessary then to run standalone. Add it to your page and you should have window.convertHTML
available.
Thanks! I did that and it worked.
The virtual-dom
offers a standalone version in its dist/
dir. Maybe you guys could include something like that too in the future!
Best,
I would like to avoid the
require
function and use the basicwindow.something
syntax, because the legacy of my current project. Is that possible?