Quokka plugin to enable browser environment via jsdom
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

Quokka.js plugin to enable browser-like environment via jsdom.

Install

npm install jsdom-quokka-plugin

Note that you may install the plugin to the Quokka config folder instead of installing it to your local project.

Configuration

Specify the plugin in Quokka configuration settings:

{
    "plugins": ["jsdom-quokka-plugin"]
}

If you need to, you may pass additional configuration options to the plugin:

{
    "plugins": ["jsdom-quokka-plugin"],
    "jsdom": {
        "file": "/html/file/path"
        "html": "...",
        "userAgent": "...",
        "config": {...}
    }
}

The jsdom.file setting allows to specify a path to any HTML file.

The jsdom.html setting allows to specify any HTML as a string.

The jsdom.config setting is the jsdom config setting.

Example

For example, running Quokka on a file like

({
    plugins: 'jsdom-quokka-plugin',
    jsdom: {html: `<div id="test">Hello</div>`}
})

const testDiv = document.getElementById('test');

console.log(testDiv.innerHTML);

displays

screen shot 2018-03-08 at 1 12 27 pm

In this example, inline Quokka config is used. You may also place the config into the global Quokka config file or into your package.json.